From c3780f23a5e543e675894fc388e3bc6f4f48c8a3 Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Fri, 6 Sep 2019 10:31:39 +0300 Subject: [PATCH] [metadata] Fix leaks when handling a few attributes (mono/mono#16675) Callers of mono_reflection_create_custom_attr_data_args_noalloc were leaking some of the returned information. Accessed attributes are FixedBufferAttribute and UnmanagedFunctionPointerAttribute. Commit migrated from https://github.com/mono/mono/commit/e49be5b9ec63e526d6bec04a957cbe48753b651b --- src/mono/mono/metadata/marshal-ilgen.c | 1 + src/mono/mono/metadata/marshal.c | 2 ++ src/mono/mono/mini/debugger-agent.c | 1 + 3 files changed, 4 insertions(+) diff --git a/src/mono/mono/metadata/marshal-ilgen.c b/src/mono/mono/metadata/marshal-ilgen.c index 0f126a0..6ebc55c 100644 --- a/src/mono/mono/metadata/marshal-ilgen.c +++ b/src/mono/mono/metadata/marshal-ilgen.c @@ -182,6 +182,7 @@ get_fixed_buffer_attr (MonoClassField *field, MonoType **out_etype, int *out_len return FALSE; *out_etype = (MonoType*)typed_args [0]; *out_len = *(gint32*)typed_args [1]; + g_free (typed_args [1]); g_free (typed_args); g_free (named_args); g_free (arginfo); diff --git a/src/mono/mono/metadata/marshal.c b/src/mono/mono/metadata/marshal.c index 698bc58..cc0b223 100644 --- a/src/mono/mono/metadata/marshal.c +++ b/src/mono/mono/metadata/marshal.c @@ -3934,7 +3934,9 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, } else { g_assert_not_reached (); } + g_free (named_args [i]); } + g_free (typed_args [0]); g_free (typed_args); g_free (named_args); g_free (arginfo); diff --git a/src/mono/mono/mini/debugger-agent.c b/src/mono/mono/mini/debugger-agent.c index 0f1405a..9cdd5d1 100644 --- a/src/mono/mono/mini/debugger-agent.c +++ b/src/mono/mono/mini/debugger-agent.c @@ -3250,6 +3250,7 @@ static gint32 isFixedSizeArray (MonoClassField *f) goto leave; } ret = *(gint32*)typed_args [1]; + g_free (typed_args [1]); g_free (typed_args); g_free (named_args); g_free (arginfo); -- 2.7.4