]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Issue #857: fix a few places where json_tokener should have been returning json_token...
authorEric Hawicz <erh+git@nimenees.com>
Sun, 21 Apr 2024 14:37:16 +0000 (10:37 -0400)
committerEric Hawicz <erh+git@nimenees.com>
Sun, 21 Apr 2024 14:37:16 +0000 (10:37 -0400)
json_tokener.c

index e8244a31bb0b42417e767054527be7be91e71ff6..cc355277383300b4f462612d8743383193ba3c66 100644 (file)
@@ -344,6 +344,7 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
                newloc = newlocale(LC_NUMERIC_MASK, "C", duploc);
                if (newloc == NULL)
                {
+                       tok->err = json_tokener_error_memory;
                        freelocale(duploc);
                        return NULL;
                }
@@ -362,7 +363,10 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
                {
                        oldlocale = strdup(tmplocale);
                        if (oldlocale == NULL)
+                       {
+                               tok->err = json_tokener_error_memory;
                                return NULL;
+                       }
                }
                setlocale(LC_NUMERIC, "C");
        }
@@ -1257,7 +1261,11 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
                        goto redo_char;
 
                case json_tokener_state_object_value_add:
-                       json_object_object_add(current, obj_field_name, obj);
+                       if (json_object_object_add(current, obj_field_name, obj) != 0)
+                       {
+                               tok->err = json_tokener_error_memory;
+                               goto out;
+                       }
                        free(obj_field_name);
                        obj_field_name = NULL;
                        saved_state = json_tokener_state_object_sep;