From 15d28c8ce0a7f2d59edd7f068e931041d68511e2 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Tue, 17 Apr 2012 23:19:16 +0200 Subject: 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 --- libc/misc/locale/locale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libc') diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c index 40303ab14..e8fddf67c 100644 --- a/libc/misc/locale/locale.c +++ b/libc/misc/locale/locale.c @@ -1292,7 +1292,7 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base) } #else if (!base) { - base = malloc(sizeof(struct __uclibc_locale_struct)); + base = calloc(1, sizeof(struct __uclibc_locale_struct)); if (base == NULL) return base; _locale_init_l(base); -- cgit v1.2.3