Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2012-10-23 23:39:32 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-10-23 23:39:32 +0400
commit9edec9f0f32768ddd22d39ef3168f1afdf170f56 (patch)
treedc1a8162141f828c791f26bf903c5fe3772765c3 /source/blender/blenfont
parent84032e97aa24d84424bac5639a99b3251cc9c8e7 (diff)
Fix #2 for [#32954] Crash when activating 'International Fonts' in User Preferences
I though allocating zero-sized mem would return a NULL pointer, but it looks like it does not... :/ Anyway, Blender should no more crash in case languages file is missing, will just use default (system) locale...
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/intern/blf_lang.c73
1 files changed, 40 insertions, 33 deletions
diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c
index 5ad06148f01..9f4cf72d120 100644
--- a/source/blender/blenfont/intern/blf_lang.c
+++ b/source/blender/blenfont/intern/blf_lang.c
@@ -82,7 +82,11 @@ static void free_locales(void)
MEM_freeN((void*)locales_menu[idx].description); /* Also frees locales's relevant value! */
}
MEM_freeN(locales);
+ locales = NULL;
+ }
+ if (locales_menu) {
MEM_freeN(locales_menu);
+ locales_menu = NULL;
}
num_locales = num_locales_menu = 0;
}
@@ -119,46 +123,49 @@ static void fill_locales(void)
num_locales_menu++; /* The "closing" void item... */
/* And now, buil locales and locale_menu! */
- locales = MEM_callocN(num_locales * sizeof(char*), __func__);
locales_menu = MEM_callocN(num_locales_menu * sizeof(EnumPropertyItem), __func__);
line = lines;
- while (line) {
- int id;
- char *loc, *sep1, *sep2;
-
- str = (char*) line->link;
- if (str[0] == '#' || str[0] == '\0') {
- line = line->next;
- continue;
- }
+ /* Do not allocate locales with zero-sized mem, as LOCALE macro uses NULL locales as invalid marker! */
+ if (num_locales > 0) {
+ locales = MEM_callocN(num_locales * sizeof(char*), __func__);
+ while (line) {
+ int id;
+ char *loc, *sep1, *sep2;
+
+ str = (char*) line->link;
+ if (str[0] == '#' || str[0] == '\0') {
+ line = line->next;
+ continue;
+ }
- id = atoi(str);
- sep1 = strchr(str, ':');
- if (sep1) {
- sep1++;
- sep2 = strchr(sep1, ':');
- if (sep2) {
-
- locales_menu[idx].value = id;
- locales_menu[idx].icon = 0;
- locales_menu[idx].name = BLI_strdupn(sep1, sep2 - sep1);
- locales_menu[idx].identifier = loc = BLI_strdup(sep2 + 1);
- if (id == 0) {
- /* The DEFAULT item... */
- if (BLI_strnlen(loc, 2))
- locales[id] = locales_menu[idx].description = BLI_strdup("");
- /* Menu "label", not to be stored in locales! */
+ id = atoi(str);
+ sep1 = strchr(str, ':');
+ if (sep1) {
+ sep1++;
+ sep2 = strchr(sep1, ':');
+ if (sep2) {
+
+ locales_menu[idx].value = id;
+ locales_menu[idx].icon = 0;
+ locales_menu[idx].name = BLI_strdupn(sep1, sep2 - sep1);
+ locales_menu[idx].identifier = loc = BLI_strdup(sep2 + 1);
+ if (id == 0) {
+ /* The DEFAULT item... */
+ if (BLI_strnlen(loc, 2))
+ locales[id] = locales_menu[idx].description = BLI_strdup("");
+ /* Menu "label", not to be stored in locales! */
+ else
+ locales_menu[idx].description = BLI_strdup("");
+ }
else
- locales_menu[idx].description = BLI_strdup("");
- }
- else
- locales[id] = locales_menu[idx].description = BLI_strdup(loc);
- idx++;
+ locales[id] = locales_menu[idx].description = BLI_strdup(loc);
+ idx++;
+ }
}
- }
- line = line->next;
+ line = line->next;
+ }
}
/* Add closing item to menu! */