Bug 1291077 - Remove a use of JS_strdup from Intl.cpp. r=sfink

This commit is contained in:
Jeff Walden 2014-07-21 19:09:36 -04:00
Родитель 099e7246db
Коммит f316e4cdc9
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -542,13 +542,13 @@ intl_availableLocales(JSContext* cx, CountAvailable countAvailable,
RootedValue t(cx, BooleanValue(true)); RootedValue t(cx, BooleanValue(true));
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
const char* locale = getAvailable(i); const char* locale = getAvailable(i);
ScopedJSFreePtr<char> lang(JS_strdup(cx, locale)); auto lang = DuplicateString(cx, locale);
if (!lang) if (!lang)
return false; return false;
char* p; char* p;
while ((p = strchr(lang, '_'))) while ((p = strchr(lang.get(), '_')))
*p = '-'; *p = '-';
RootedAtom a(cx, Atomize(cx, lang, strlen(lang))); RootedAtom a(cx, Atomize(cx, lang.get(), strlen(lang.get())));
if (!a) if (!a)
return false; return false;
if (!DefineProperty(cx, locales, a->asPropertyName(), t, nullptr, nullptr, if (!DefineProperty(cx, locales, a->asPropertyName(), t, nullptr, nullptr,