diff options
author | theraven <theraven@FreeBSD.org> | 2011-11-22 14:11:42 +0000 |
---|---|---|
committer | theraven <theraven@FreeBSD.org> | 2011-11-22 14:11:42 +0000 |
commit | da7efa5819516076c7872ef1ed39b29bdf2643af (patch) | |
tree | 90000ae9e05b0450d6bf4dc5cd1dbdc79a279992 | |
parent | af14be937d41261e713de94faebda1540822dc94 (diff) | |
download | FreeBSD-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)
-rw-r--r-- | lib/libc/locale/xlocale.c | 7 |
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]); } |