Issue #195: Actually call uselocale() in the new locale handling code in json_tokener.

Also, be sure the right locale_t is freed if we fail on the second uselocale.
Finally, fix test_locale so it *doesn't* use json_object_to_json_string as
 that will simple re-emit the original parsed string values.
This commit is contained in:
Eric Haszlakiewicz
2016-07-31 14:39:56 -04:00
parent 4091b9c87e
commit fa76e4a8c9
3 changed files with 25 additions and 5 deletions

View File

@@ -262,12 +262,16 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
// XXX at least Debian 8.4 has a bug in newlocale where it doesn't
// change the decimal separator unless you set LC_TIME!
if (newloc)
newloc = newlocale(LC_TIME, "C", newloc);
{
duploc = newloc; // original duploc has been freed by newlocale()
newloc = newlocale(LC_TIME, "C", duploc);
}
if (newloc == NULL)
{
freelocale(duploc);
return NULL;
}
uselocale(newloc);
}
#elif defined(HAVE_SETLOCALE)
{