Handle yet another out-of-memory condition.
duplocale() can return NULL, with errno set to ENOMEM. In this case, bail out and set the current error code to json_tokener_error_memory.
This commit is contained in:
1 parent
31a22fb2da
commit
833233faa8
1 file changed
+5
@@ -341,6 +341,11 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
|
|||||||
#ifdef HAVE_USELOCALE
|
#ifdef HAVE_USELOCALE
|
||||||
{
|
{
|
||||||
locale_t duploc = duplocale(oldlocale);
|
locale_t duploc = duplocale(oldlocale);
|
||||||
|
if (duploc == NULL && errno == ENOMEM)
|
||||||
|
{
|
||||||
|
tok->err = json_tokener_error_memory;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
newloc = newlocale(LC_NUMERIC_MASK, "C", duploc);
|
newloc = newlocale(LC_NUMERIC_MASK, "C", duploc);
|
||||||
if (newloc == NULL)
|
if (newloc == NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user