summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale
diff options
context:
space:
mode:
authortheraven <theraven@FreeBSD.org>2011-11-22 14:11:42 +0000
committertheraven <theraven@FreeBSD.org>2011-11-22 14:11:42 +0000
commitda7efa5819516076c7872ef1ed39b29bdf2643af (patch)
tree90000ae9e05b0450d6bf4dc5cd1dbdc79a279992 /lib/libc/locale
parentaf14be937d41261e713de94faebda1540822dc94 (diff)
downloadFreeBSD-src-da7efa5819516076c7872ef1ed39b29bdf2643af.zip
FreeBSD-src-da7efa5819516076c7872ef1ed39b29bdf2643af.tar.gz
Fix a crash when trying to duplicate a locale that contains some implicit C locale components.
Reported by: Michael Butler Approved by: dim (mentor)
Diffstat (limited to 'lib/libc/locale')
-rw-r--r--lib/libc/locale/xlocale.c7
1 files changed, 6 insertions, 1 deletions
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]);
}
OpenPOWER on IntegriCloud