Author: kumpera
Date: 2007-09-06 10:51:09 -0400 (Thu, 06 Sep 2007)
New Revision: 85422

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/icall.c
   trunk/mono/mono/metadata/reflection.c
   trunk/mono/mono/metadata/reflection.h
Log:
2007-09-16  Rodrigo Kumpera  <[EMAIL PROTECTED]>

        * reflection.h: exposed mono_reflection_free_type_info
        * reflection.c (mono_reflection_get_type_internal): type_args is always 
freed
        since mono_reflection_bind_generic_parameters makes a copy of it.
        * reflection.c (free_type_info): subinfos should be freed.
        * reflection.c (free_type_info): renamed to 
mono_reflection_free_type_info and 
        made non static.
        * icall.c (type_from_name and 
ves_icall_System_Reflection_Assembly_InternalGetType):
        replaced explicit cleanup of MonoTypeNameParse struct with a call to 
mono_reflection_free_type_info,
        this fixes #82695 and #81726.
   



Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2007-09-06 14:44:34 UTC (rev 85421)
+++ trunk/mono/mono/metadata/ChangeLog  2007-09-06 14:51:09 UTC (rev 85422)
@@ -1,3 +1,16 @@
+2007-09-16  Rodrigo Kumpera  <[EMAIL PROTECTED]>
+
+       * reflection.h: exposed mono_reflection_free_type_info
+       * reflection.c (mono_reflection_get_type_internal): type_args is always 
freed
+       since mono_reflection_bind_generic_parameters makes a copy of it.
+       * reflection.c (free_type_info): subinfos should be freed.
+       * reflection.c (free_type_info): renamed to 
mono_reflection_free_type_info and 
+       made non static.
+       * icall.c (type_from_name and 
ves_icall_System_Reflection_Assembly_InternalGetType):
+       replaced explicit cleanup of MonoTypeNameParse struct with a call to 
mono_reflection_free_type_info,
+       this fixes #82695 and #81726.
+   
+
 2007-09-03  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * process.h, process.c:  added support for user profile/info in

Modified: trunk/mono/mono/metadata/icall.c
===================================================================
--- trunk/mono/mono/metadata/icall.c    2007-09-06 14:44:34 UTC (rev 85421)
+++ trunk/mono/mono/metadata/icall.c    2007-09-06 14:51:09 UTC (rev 85422)
@@ -1055,8 +1055,7 @@
 
        /* mono_reflection_parse_type() mangles the string */
        if (!mono_reflection_parse_type (temp_str, &info)) {
-               g_list_free (info.modifiers);
-               g_list_free (info.nested);
+               mono_reflection_free_type_info (&info);
                g_free (temp_str);
                return NULL;
        }
@@ -1092,8 +1091,7 @@
        if (!info.assembly.name && !type) /* try mscorlib */
                type = mono_reflection_get_type (NULL, &info, ignoreCase, 
&type_resolve);
 
-       g_list_free (info.modifiers);
-       g_list_free (info.nested);
+       mono_reflection_free_type_info (&info);
        g_free (temp_str);
 
        if (!type) 
@@ -3843,8 +3841,7 @@
        /*g_print ("requested type %s in %s\n", str, 
assembly->assembly->aname.name);*/
        if (!mono_reflection_parse_type (str, &info)) {
                g_free (str);
-               g_list_free (info.modifiers);
-               g_list_free (info.nested);
+               mono_reflection_free_type_info (&info);
                if (throwOnError) /* uhm: this is a parse error, though... */
                        mono_raise_exception (mono_get_exception_type_load 
(name, NULL));
                /*g_print ("failed parse\n");*/
@@ -3885,8 +3882,7 @@
                else
                        type = mono_reflection_get_type 
(assembly->assembly->image, &info, ignoreCase, &type_resolve);
        g_free (str);
-       g_list_free (info.modifiers);
-       g_list_free (info.nested);
+       mono_reflection_free_type_info (&info);
        if (!type) {
                MonoException *e = NULL;
                

Modified: trunk/mono/mono/metadata/reflection.c
===================================================================
--- trunk/mono/mono/metadata/reflection.c       2007-09-06 14:44:34 UTC (rev 
85421)
+++ trunk/mono/mono/metadata/reflection.c       2007-09-06 14:51:09 UTC (rev 
85422)
@@ -6076,6 +6076,7 @@
 
        start = p = w = name;
 
+       //FIXME could we just zero the whole struct? memset (&info, 0, sizeof 
(MonoTypeNameParse))
        memset (&info->assembly, 0, sizeof (MonoAssemblyName));
        info->name = info->name_space = NULL;
        info->nested = NULL;
@@ -6362,10 +6363,9 @@
                instance = mono_reflection_bind_generic_parameters (
                        the_type, info->type_arguments->len, type_args);
 
-               if (!instance) {
-                       g_free (type_args);
+               g_free (type_args);
+               if (!instance)
                        return NULL;
-               }
 
                klass = mono_class_from_mono_type (instance);
        }
@@ -6465,8 +6465,8 @@
        return type;
 }
 
-static void
-free_type_info (MonoTypeNameParse *info)
+void
+mono_reflection_free_type_info (MonoTypeNameParse *info)
 {
        g_list_free (info->modifiers);
        g_list_free (info->nested);
@@ -6477,7 +6477,9 @@
                for (i = 0; i < info->type_arguments->len; i++) {
                        MonoTypeNameParse *subinfo = g_ptr_array_index 
(info->type_arguments, i);
 
-                       free_type_info (subinfo);
+                       mono_reflection_free_type_info (subinfo);
+                       /*We free the subinfo since it is allocated by 
_mono_reflection_parse_type*/
+                       g_free (subinfo);
                }
 
                g_ptr_array_free (info->type_arguments, TRUE);
@@ -6510,7 +6512,7 @@
        }
 
        g_free (tmp);
-       free_type_info (&info);
+       mono_reflection_free_type_info (&info);
        return type;
 }
 

Modified: trunk/mono/mono/metadata/reflection.h
===================================================================
--- trunk/mono/mono/metadata/reflection.h       2007-09-06 14:44:34 UTC (rev 
85421)
+++ trunk/mono/mono/metadata/reflection.h       2007-09-06 14:51:09 UTC (rev 
85422)
@@ -50,6 +50,7 @@
 
 int           mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
 MonoType*     mono_reflection_get_type   (MonoImage* image, MonoTypeNameParse 
*info, gboolean ignorecase, gboolean *type_resolve);
+void          mono_reflection_free_type_info (MonoTypeNameParse *info);
 MonoType*     mono_reflection_type_from_name (char *name, MonoImage *image);
 guint32       mono_reflection_get_token (MonoObject *obj);
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to