* get.c (get_type): Make robust to invalid types.
authorRaja R Harinath <harinath@hurrynot.org>
Thu, 16 Jul 2009 17:17:00 +0000 (17:17 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Thu, 16 Jul 2009 17:17:00 +0000 (17:17 -0000)
svn path=/trunk/mono/; revision=138066

mono/dis/ChangeLog
mono/dis/get.c

index f02b3d60a83f9962532262c09914150a6a78cd50..7a292cc92473db3b4c7430f8c57748e1919b69b9 100644 (file)
@@ -1,3 +1,7 @@
+2009-07-16  Raja R Harinath  <harinath@hurrynot.org>
+
+       * get.c (get_type): Make robust to invalid types.
+
 2009-07-16  Marek Habersack  <mhabersack@novell.com>
 
        * main.c: added new --presources option which prints manifest
index 8bdea71a173433b3da431bc92274bbef3d882fb9..0651772fc3439adc100c5e2fb43cb68faee679f5 100644 (file)
@@ -1308,7 +1308,24 @@ get_type (MonoImage *m, const char *ptr, char **result, gboolean is_def, MonoGen
 
        default:
                t = mono_metadata_parse_type_full (m, container, MONO_PARSE_TYPE, 0, start, &ptr);
-               *result = dis_stringify_type (m, t, is_def);
+               if (t) {
+                       *result = dis_stringify_type (m, t, is_def);
+               } else {
+                       GString *err = g_string_new ("@!#$<InvalidType>$#!@");
+                       if (container)
+                               t = mono_metadata_parse_type_full (m, NULL, MONO_PARSE_TYPE, 0, start, &ptr);
+                       if (t) {
+                               char *name = dis_stringify_type (m, t, is_def);
+                               g_warning ("Encountered a generic type inappropriate for its context");
+                               g_string_append (err, " // ");
+                               g_string_append (err, name);
+                               g_free (name);
+                       } else {
+                               g_warning ("Encountered an invalid type");
+                       }
+                       *result = g_string_free (err, FALSE);
+               }
+
                break;
        }