Move the sgen_*_os_memory APIs to memgov.
[mono.git] / mono / metadata / icall.c
index b7873f5caac24caff2929e27b66d827fda96bb39..e58903aa88ae32ce21eab684712b7c40e4b61aa6 100644 (file)
@@ -8,7 +8,7 @@
  *
  * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
  * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
- * Copyright 2011 Xamarin Inc (http://www.xamarin.com).
+ * Copyright 2011-2012 Xamarin Inc (http://www.xamarin.com).
  */
 
 #include <config.h>
@@ -7674,6 +7674,7 @@ base64_to_byte_array (gunichar2 *start, gint ilength, MonoBoolean allowWhitespac
        gint a [4], b [4];
        MonoException *exc;
 
+       int havePadding = 0;
        ignored = 0;
        last = prev_last = 0, prev2_last = 0;
        for (i = 0; i < ilength; i++) {
@@ -7685,7 +7686,13 @@ base64_to_byte_array (gunichar2 *start, gint ilength, MonoBoolean allowWhitespac
                        mono_raise_exception (exc);
                } else if (isspace (c)) {
                        ignored++;
+               } else if (havePadding && c != '=') {
+                       exc = mono_exception_from_name_msg (mono_get_corlib (),
+                               "System", "FormatException",
+                               "Invalid character found.");
+                       mono_raise_exception (exc);
                } else {
+                       if (c == '=') havePadding = 1;
                        prev2_last = prev_last;
                        prev_last = last;
                        last = c;
@@ -8048,11 +8055,13 @@ concat_class_name (char *buf, int bufsize, MonoClass *klass)
        return nspacelen + cnamelen;
 }
 
+#ifdef DISABLE_ICALL_TABLES
 static void
 no_icall_table (void)
 {
        g_assert_not_reached ();
 }
+#endif
 
 gpointer
 mono_lookup_internal_call (MonoMethod *method)
@@ -8063,7 +8072,7 @@ mono_lookup_internal_call (MonoMethod *method)
        int typelen = 0, mlen, siglen;
        gpointer res;
 #ifndef DISABLE_ICALL_TABLES
-       const IcallTypeDesc *imap;
+       const IcallTypeDesc *imap = NULL;
 #endif
 
        g_assert (method != NULL);
@@ -8090,6 +8099,10 @@ mono_lookup_internal_call (MonoMethod *method)
                        return NULL;
        }
 
+#ifndef DISABLE_ICALL_TABLES
+       imap = find_class_icalls (mname);
+#endif
+
        mname [typelen] = ':';
        mname [typelen + 1] = ':';
 
@@ -8126,10 +8139,12 @@ mono_lookup_internal_call (MonoMethod *method)
 #ifdef DISABLE_ICALL_TABLES
        mono_loader_unlock ();
        /* Fail only when the result is actually used */
-       return no_icall_table;
+       /* mono_marshal_get_native_wrapper () depends on this */
+       if (method->klass == mono_defaults.string_class && !strcmp (method->name, ".ctor"))
+               return ves_icall_System_String_ctor_RedirectToCreateString;
+       else
+               return no_icall_table;
 #else
-       imap = find_class_icalls (mname);
-
        /* it wasn't found in the static call tables */
        if (!imap) {
                mono_loader_unlock ();
@@ -8162,11 +8177,13 @@ mono_lookup_internal_call (MonoMethod *method)
 #endif
 }
 
+#ifdef ENABLE_ICALL_SYMBOL_MAP
 static int
 func_cmp (gconstpointer key, gconstpointer p)
 {
        return (gsize)key - (gsize)*(gsize*)p;
 }
+#endif
 
 /*
  * mono_lookup_icall_symbol: