From da7efa5819516076c7872ef1ed39b29bdf2643af Mon Sep 17 00:00:00 2001 From: theraven Date: Tue, 22 Nov 2011 14:11:42 +0000 Subject: Fix a crash when trying to duplicate a locale that contains some implicit C locale components. Reported by: Michael Butler Approved by: dim (mentor) --- lib/libc/locale/xlocale.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/locale/xlocale.c b/lib/libc/locale/xlocale.c index f14f952..ece0076 100644 --- a/lib/libc/locale/xlocale.c +++ b/lib/libc/locale/xlocale.c @@ -200,8 +200,13 @@ static int dupcomponent(int type, locale_t base, locale_t new) if (new->components[type]) { strncpy(new->components[type]->locale, src->locale, ENCODING_LEN); } - } else { + } else if (base->components[type]) { new->components[type] = xlocale_retain(base->components[type]); + } else { + /* If the component was NULL, return success - if base is a valid + * locale then the flag indicating that this isn't present should be + * set. If it isn't a valid locale, then we're stuck anyway. */ + return 1; } return (0 != new->components[type]); } -- cgit v1.1