Skip to content

Commit

Permalink
[mono] Reuse handles inside a loop in reflection_create_dynamic_metho…
Browse files Browse the repository at this point in the history
…d (). (#79716)

This fixes the 'reflection_create_dynamic_method USED x handles' warnings.
  • Loading branch information
vargaz committed Dec 28, 2022
1 parent 7aba441 commit fa7d049
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mono/mono/metadata/sre.c
Expand Up @@ -3949,6 +3949,7 @@ reflection_create_dynamic_method (MonoReflectionDynamicMethodHandle ref_mb, Mono
gboolean ret = TRUE;
MonoReflectionDynamicMethod *mb;
MonoAssembly *ass = NULL;
MonoObjectHandle ref_handle = MONO_HANDLE_NEW (MonoObject, NULL);

error_init (error);

Expand Down Expand Up @@ -3977,8 +3978,11 @@ reflection_create_dynamic_method (MonoReflectionDynamicMethodHandle ref_mb, Mono
for (gint32 i = 0; i < mb->nrefs; i += 2) {
MonoClass *handle_class;
gpointer ref;
MonoObject *obj = mono_array_get_internal (mb->refs, MonoObject*, i);
MONO_HANDLE_PIN (obj);
MonoObject *obj;

obj = mono_array_get_internal (mb->refs, MonoObject*, i);
/* Reuse the handle since we are inside a loop */
MONO_HANDLE_ASSIGN_RAW (ref_handle, obj);

if (strcmp (obj->vtable->klass->name, "DynamicMethod") == 0) {
MonoReflectionDynamicMethod *method = (MonoReflectionDynamicMethod*)obj;
Expand Down

0 comments on commit fa7d049

Please sign in to comment.