From 7be236fd2e290765b11acf5dc56036242aa29171 Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Thu, 14 Oct 2021 16:35:20 -0700 Subject: [PATCH 1/2] Fix null being passed to g_path_get_dirname when probing in wasm --- src/mono/mono/metadata/native-library.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index eae091bc6c15c3..f8ecbd53f2c717 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -526,7 +526,10 @@ netcore_probe_for_module (MonoImage *image, const char *file_name, int flags) module = netcore_probe_for_module_variations (pinvoke_search_directories[i], file_name, lflags); // Check the assembly directory if the search flag is set and the image exists - if (flags & DLLIMPORTSEARCHPATH_ASSEMBLY_DIRECTORY && image != NULL && module == NULL) { + if ( + flags & DLLIMPORTSEARCHPATH_ASSEMBLY_DIRECTORY && image != NULL && + module == NULL && (image->filename != NULL) + ) { char *mdirname = g_path_get_dirname (image->filename); if (mdirname) module = netcore_probe_for_module_variations (mdirname, file_name, lflags); From ed4e952cf5b4ae2f012fc2420672dbb9b65bf9d6 Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Thu, 14 Oct 2021 18:15:28 -0700 Subject: [PATCH 2/2] Update src/mono/mono/metadata/native-library.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Aleksey Kliger (λgeek) --- src/mono/mono/metadata/native-library.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index f8ecbd53f2c717..e5d4503684f8be 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -526,10 +526,8 @@ netcore_probe_for_module (MonoImage *image, const char *file_name, int flags) module = netcore_probe_for_module_variations (pinvoke_search_directories[i], file_name, lflags); // Check the assembly directory if the search flag is set and the image exists - if ( - flags & DLLIMPORTSEARCHPATH_ASSEMBLY_DIRECTORY && image != NULL && - module == NULL && (image->filename != NULL) - ) { + if ((flags & DLLIMPORTSEARCHPATH_ASSEMBLY_DIRECTORY) != 0 && image != NULL && + module == NULL && (image->filename != NULL)) { char *mdirname = g_path_get_dirname (image->filename); if (mdirname) module = netcore_probe_for_module_variations (mdirname, file_name, lflags);