Browse Source

locale: avoid segfault freelocale()

PR 4964

Eric Nadler writes:
It looks to me like the base structure is not fully initialized
with 0 (only a subset of the structure is initialized).
This later results in a free of base->collate.index2weight in
_locale_set_l.
This free tries to free uninitialized memory and segfaults.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Bernhard Reutner-Fischer 13 years ago
parent
commit
15d28c8ce0
1 changed files with 1 additions and 1 deletions
  1. 1 1
      libc/misc/locale/locale.c

+ 1 - 1
libc/misc/locale/locale.c

@@ -1292,7 +1292,7 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
 	}
 	}
 #else
 #else
 	if (!base) {
 	if (!base) {
-		base = malloc(sizeof(struct __uclibc_locale_struct));
+		base = calloc(1, sizeof(struct __uclibc_locale_struct));
 		if (base == NULL)
 		if (base == NULL)
 			return base;
 			return base;
 		_locale_init_l(base);
 		_locale_init_l(base);