[metadata] Fix a potential crasher.
[mono.git] / mono / metadata / debug-helpers.c
index e3cfd09b61ed439605aadb0db8bd7383c2d1d2f9..a20e8ae06e03a9ade8d5e64419f4d0a4b9122220 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * console-io.c: ConsoleDriver internal calls
+ * debug-helpers.c:
  *
  * Author:
  *     Mono Project (http://www.mono-project.com)
@@ -12,6 +12,7 @@
 #include "mono/metadata/opcodes.h"
 #include "mono/metadata/metadata-internals.h"
 #include "mono/metadata/class-internals.h"
+#include "mono/metadata/object-internals.h"
 #include "mono/metadata/mono-endian.h"
 #include "mono/metadata/debug-helpers.h"
 #include "mono/metadata/tabledefs.h"
@@ -325,10 +326,10 @@ mono_method_desc_new (const char *name, gboolean include_namespace)
                g_free (class_nspace);
                return NULL;
        }
-       *method_name++ = 0;
        /* allow two :: to separate the method name */
-       if (*method_name == ':')
-               method_name++;
+       if (method_name != class_nspace && method_name [-1] == ':')
+               method_name [-1] = 0;
+       *method_name++ = 0;
        class_name = strrchr (class_nspace, '.');
        if (class_name) {
                *class_name++ = 0;
@@ -467,6 +468,8 @@ match_class (MonoMethodDesc *desc, int pos, MonoClass *klass)
 gboolean
 mono_method_desc_full_match (MonoMethodDesc *desc, MonoMethod *method)
 {
+       if (!desc->klass)
+               return FALSE;
        if (!match_class (desc, strlen (desc->klass), method->klass))
                return FALSE;
 
@@ -843,7 +846,7 @@ mono_object_describe (MonoObject *obj)
                MonoArray *array = (MonoArray*)obj;
                sep = print_name_space (klass);
                g_print ("%s%s", sep, klass->name);
-               g_print (" at %p, rank: %d, length: %d\n", obj, klass->rank, mono_array_length (array));
+               g_print (" at %p, rank: %d, length: %d\n", obj, klass->rank, (int)mono_array_length (array));
        } else {
                sep = print_name_space (klass);
                g_print ("%s%s", sep, klass->name);
@@ -1002,7 +1005,7 @@ mono_class_describe_statics (MonoClass* klass)
 
        if (!vtable)
                return;
-       if (!(addr = vtable->data))
+       if (!(addr = mono_vtable_get_static_field_data (vtable)))
                return;
 
        for (p = klass; p != NULL; p = p->parent) {
@@ -1019,4 +1022,3 @@ mono_class_describe_statics (MonoClass* klass)
                }
        }
 }
-