Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lucia <rylucia@microsoft.com>2021-05-10 16:30:00 +0300
committerGitHub <noreply@github.com>2021-05-10 16:30:00 +0300
commit28a101a8ab5a3852bcb8876edfbc9d9f1360cd35 (patch)
treead2dabfc6291d7c5883d8c791ad18314c0f98182
parent0449008883dfe8cf108c74ba1167f99723d5a3a3 (diff)
[2020-02] Fix leak in assembly-specific dllmap lookups (#21053)
-rw-r--r--mono/metadata/native-library.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/mono/metadata/native-library.c b/mono/metadata/native-library.c
index d57252f1b1d..0f556794a38 100644
--- a/mono/metadata/native-library.c
+++ b/mono/metadata/native-library.c
@@ -83,9 +83,9 @@ GENERATE_GET_CLASS_WITH_CACHE (native_library, "System.Runtime.InteropServices",
* LOCKING: Assumes the relevant lock is held.
* For the global DllMap, this is `global_loader_data_mutex`, and for images it's their internal lock.
*/
-static int
+static gboolean
mono_dllmap_lookup_list (MonoDllMap *dll_map, const char *dll, const char* func, const char **rdll, const char **rfunc) {
- int found = 0;
+ gboolean found = FALSE;
*rdll = dll;
*rfunc = func;
@@ -107,7 +107,7 @@ mono_dllmap_lookup_list (MonoDllMap *dll_map, const char *dll, const char* func,
if (!found && dll_map->target) {
*rdll = dll_map->target;
- found = 1;
+ found = TRUE;
/* we don't quit here, because we could find a full
* entry that also matches the function, which takes priority.
*/
@@ -120,8 +120,6 @@ mono_dllmap_lookup_list (MonoDllMap *dll_map, const char *dll, const char* func,
}
exit:
- *rdll = g_strdup (*rdll);
- *rfunc = g_strdup (*rfunc);
return found;
}
@@ -129,10 +127,10 @@ exit:
* The locking and GC state transitions here are wonky due to the fact the image lock is a coop lock
* and the global loader data lock is an OS lock.
*/
-static int
+static gboolean
mono_dllmap_lookup (MonoImage *assembly, const char *dll, const char* func, const char **rdll, const char **rfunc)
{
- int res;
+ gboolean res;
MONO_REQ_GC_UNSAFE_MODE;
@@ -141,7 +139,7 @@ mono_dllmap_lookup (MonoImage *assembly, const char *dll, const char* func, cons
res = mono_dllmap_lookup_list (assembly->dll_map, dll, func, rdll, rfunc);
mono_image_unlock (assembly);
if (res)
- return res;
+ goto leave;
}
MONO_ENTER_GC_SAFE;
@@ -152,6 +150,10 @@ mono_dllmap_lookup (MonoImage *assembly, const char *dll, const char* func, cons
MONO_EXIT_GC_SAFE;
+leave:
+ *rdll = g_strdup (*rdll);
+ *rfunc = g_strdup (*rfunc);
+
return res;
}