2010-01-11 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / metadata / locales.c
index 0a161e12e1e7369b7ce93a44906bbf1b9653e35e..1b17ca1d1b1427e6739d32126c13715d8c91784b 100644 (file)
@@ -195,6 +195,8 @@ ves_icall_System_Globalization_CultureInfo_construct_number_format (MonoCultureI
        MONO_ARCH_SAVE_REGS;
 
        g_assert (this->number_format != 0);
+       if (this->number_index < 0)
+               return;
 
        number = this->number_format;
        nfe = &number_format_entries [this->number_index];
@@ -301,7 +303,10 @@ construct_culture_from_specific_name (MonoCultureInfo *ci, gchar *name)
        if (entry->lcid != entry->specific_lcid)
                entry = culture_info_entry_from_lcid (entry->specific_lcid);
 
-       return construct_culture (ci, entry);
+       if (entry)
+               return construct_culture (ci, entry);
+       else
+               return FALSE;
 }
 
 static const CultureInfoEntry*
@@ -377,7 +382,7 @@ get_current_locale_name (void)
        const gchar *p;
         gchar *c;
 
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
        locale = g_win32_getlocale ();
 #else  
        locale = get_posix_locale ();
@@ -388,7 +393,7 @@ get_current_locale_name (void)
 
        if ((p = strchr (locale, '.')) != NULL) {
                /* assume new locale can't be larger than old one? */
-               corrected = malloc (strlen (locale));
+               corrected = g_malloc (strlen (locale));
                strncpy (corrected, locale, p - locale);
                corrected [p - locale] = 0;
 
@@ -407,7 +412,7 @@ get_current_locale_name (void)
                 */
 
                if (corrected == NULL) {
-                       corrected = malloc (strlen (locale));
+                       corrected = g_malloc (strlen (locale));
                        strncpy (corrected, locale, p - locale);
                        corrected [p - locale] = 0;
                }