Skip to content

Commit fa7d049

Browse files
authored
[mono] Reuse handles inside a loop in reflection_create_dynamic_method (). (#79716)
This fixes the 'reflection_create_dynamic_method USED x handles' warnings.
1 parent 7aba441 commit fa7d049

File tree

1 file changed

+6
-2
lines changed
  • src/mono/mono/metadata

1 file changed

+6
-2
lines changed

src/mono/mono/metadata/sre.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3949,6 +3949,7 @@ reflection_create_dynamic_method (MonoReflectionDynamicMethodHandle ref_mb, Mono
39493949
gboolean ret = TRUE;
39503950
MonoReflectionDynamicMethod *mb;
39513951
MonoAssembly *ass = NULL;
3952+
MonoObjectHandle ref_handle = MONO_HANDLE_NEW (MonoObject, NULL);
39523953

39533954
error_init (error);
39543955

@@ -3977,8 +3978,11 @@ reflection_create_dynamic_method (MonoReflectionDynamicMethodHandle ref_mb, Mono
39773978
for (gint32 i = 0; i < mb->nrefs; i += 2) {
39783979
MonoClass *handle_class;
39793980
gpointer ref;
3980-
MonoObject *obj = mono_array_get_internal (mb->refs, MonoObject*, i);
3981-
MONO_HANDLE_PIN (obj);
3981+
MonoObject *obj;
3982+
3983+
obj = mono_array_get_internal (mb->refs, MonoObject*, i);
3984+
/* Reuse the handle since we are inside a loop */
3985+
MONO_HANDLE_ASSIGN_RAW (ref_handle, obj);
39823986

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

0 commit comments

Comments
 (0)