Merge pull request #2810 from kumpera/fix_hazard_free
[mono.git] / mono / metadata / coree.c
index d722271ebb7da3937db68b81cf767ddcd844df9e..326251cc140c53a575ff7e227abcdeea92bc2782 100644 (file)
@@ -5,6 +5,7 @@
  *   Kornel Pal <http://www.kornelpal.hu/>
  *
  * Copyright (C) 2008 Kornel Pal
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 
 #include <config.h>
@@ -136,13 +137,14 @@ BOOL STDMETHODCALLTYPE _CorDllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpRes
 /* Called by ntdll.dll reagardless of entry point after _CorValidateImage. */
 __int32 STDMETHODCALLTYPE _CorExeMain(void)
 {
+       MonoError error;
        MonoDomain* domain;
        MonoAssembly* assembly;
        MonoImage* image;
        MonoMethod* method;
        guint32 entry;
        gchar* file_name;
-       gchar* error;
+       gchar* corlib_version_error;
        int argc;
        gunichar2** argvw;
        gchar** argv;
@@ -152,9 +154,9 @@ __int32 STDMETHODCALLTYPE _CorExeMain(void)
        init_from_coree = TRUE;
        domain = mono_runtime_load (file_name, NULL);
 
-       error = (gchar*) mono_check_corlib_version ();
-       if (error) {
-               g_free (error);
+       corlib_version_error = (gchar*) mono_check_corlib_version ();
+       if (corlib_version_error) {
+               g_free (corlib_version_error);
                g_free (file_name);
                MessageBox (NULL, L"Corlib not in sync with this runtime.", NULL, MB_ICONERROR);
                mono_runtime_quit ();
@@ -179,9 +181,10 @@ __int32 STDMETHODCALLTYPE _CorExeMain(void)
                ExitProcess (1);
        }
 
-       method = mono_get_method (image, entry, NULL);
+       method = mono_get_method_checked (image, entry, NULL, NULL, &error);
        if (method == NULL) {
                g_free (file_name);
+               mono_error_cleanup (&error); /* FIXME don't swallow the error */
                MessageBox (NULL, L"The entry point method could not be loaded.", NULL, MB_ICONERROR);
                mono_runtime_quit ();
                ExitProcess (1);