* reflection.c (mono_type_get_object): Don't store the suplied
MonoType with type_hash. A caller which pass a type that
was mono_metadata_type_dup'ed cannot free it reliably, as type_hash
might end with a pointer to freed memory.
The solution is to use byval_arg or this_arg from the associated
MonoClass of the supplied type.
svn path=/trunk/mono/; revision=104574
+2008-05-30 Rodrigo Kumpera <rkumpera@novell.com>
+
+ * reflection.c (mono_type_get_object): Don't store the suplied
+ MonoType with type_hash. A caller which pass a type that
+ was mono_metadata_type_dup'ed cannot free it reliably, as type_hash
+ might end with a pointer to freed memory.
+ The solution is to use byval_arg or this_arg from the associated
+ MonoClass of the supplied type.
+
2008-05-29 Zoltan Varga <vargaz@gmail.com>
* icall.c: Revert the rest of the last change as it breaks the build too.
MonoReflectionType *res;
MonoClass *klass = mono_class_from_mono_type (type);
+ /*we must avoid using @type as it might have come
+ * from a mono_metadata_type_dup and the caller
+ * expects that is can be freed.
+ * Using the right type from
+ */
+ type = klass->byval_arg.byref == type->byref ? &klass->byval_arg : &klass->this_arg;
+
mono_domain_lock (domain);
if (!domain->type_hash)
domain->type_hash = mono_g_hash_table_new_type ((GHashFunc)mymono_metadata_type_hash,