Fix use of freed memory. (mono/mono#15660)
authorJay Krell <jaykrell@microsoft.com>
Tue, 16 Jul 2019 20:16:52 +0000 (13:16 -0700)
committerRyan Lucia <rylucia@microsoft.com>
Tue, 16 Jul 2019 20:16:52 +0000 (13:16 -0700)
Fix use of freed memory.
Move the free later, on the assumption that the free itself doesn't use memory now freed before it.
Found with Valgrind.

Commit migrated from https://github.com/mono/mono/commit/43f1a268045a1a3746bfd4a610b7b4874599aa38

src/mono/mono/mini/mini-runtime.c

index 71e3462..75491f1 100644 (file)
@@ -4749,8 +4749,6 @@ mini_cleanup (MonoDomain *domain)
        if (profile_options)
                g_ptr_array_free (profile_options, TRUE);
 
-       free_jit_tls_data (mono_tls_get_jit_tls ());
-
        mono_icall_cleanup ();
 
        mono_runtime_cleanup_handlers ();
@@ -4758,6 +4756,7 @@ mini_cleanup (MonoDomain *domain)
 #ifndef MONO_CROSS_COMPILE
        mono_domain_free (domain, TRUE);
 #endif
+       free_jit_tls_data (mono_tls_get_jit_tls ());
 
 #ifdef ENABLE_LLVM
        if (mono_use_llvm)