const char *new_import = NULL;
const char *orig_scope = NULL;
const char *new_scope = NULL;
+ const char *error_scope = NULL;
char *error_msg = NULL;
MonoDl *module = NULL;
gpointer addr = NULL;
new_import = g_strdup (orig_import);
#endif
+ error_scope = new_scope;
+
/* If qcalls are disabled, we fall back to the normal pinvoke code for them */
#ifndef DISABLE_QCALLS
if (strcmp (new_scope, "QCall") == 0) {
if (!module) {
mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_DLLIMPORT,
"DllImport unable to load library '%s'.",
- new_scope);
+ error_scope);
status_out->err_code = LOOKUP_PINVOKE_ERR_NO_LIB;
- status_out->err_arg = g_strdup (new_scope);
+ status_out->err_arg = g_strdup (error_scope);
goto exit;
}
if (!addr) {
#ifndef HOST_WIN32
if (strcmp (new_scope, "__Internal") == 0) {
- g_free ((char *)new_scope);
+ g_assert (error_scope == new_scope);
new_scope = g_strdup (MONO_LOADER_LIBRARY_NAME);
goto retry_with_libcoreclr;
}
piinfo->addr = addr;
exit:
+ if (error_scope != new_scope) {
+ g_free ((char *)error_scope);
+ }
g_free ((char *)new_import);
g_free ((char *)new_scope);
g_free (error_msg);