]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Handle yet another out-of-memory condition. 861/head
authorBruno Haible <bruno@clisp.org>
Sun, 21 Apr 2024 23:50:59 +0000 (01:50 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Apr 2024 23:54:10 +0000 (01:54 +0200)
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.

json_tokener.c

index cc355277383300b4f462612d8743383193ba3c66..0a86d82108a2cc8de84737d303c1820a51c5bd85 100644 (file)
@@ -341,6 +341,11 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
 #ifdef HAVE_USELOCALE
        {
                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);
                if (newloc == NULL)
                {