Browse Source

Issue #857: fix a few places where json_tokener should have been returning json_tokener_error_memory but wasn't.

tags/json-c-0.18-20240915
Eric Hawicz 1 year ago
parent
commit
31a22fb2da
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      json_tokener.c

+ 9
- 1
json_tokener.c View 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); newloc = newlocale(LC_NUMERIC_MASK, "C", duploc);
if (newloc == NULL) if (newloc == NULL)
{ {
tok->err = json_tokener_error_memory;
freelocale(duploc); freelocale(duploc);
return NULL; return NULL;
} }
@@ -362,7 +363,10 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
{ {
oldlocale = strdup(tmplocale); oldlocale = strdup(tmplocale);
if (oldlocale == NULL) if (oldlocale == NULL)
{
tok->err = json_tokener_error_memory;
return NULL; return NULL;
}
} }
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
} }
@@ -1257,7 +1261,11 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
goto redo_char; goto redo_char;


case json_tokener_state_object_value_add: 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); free(obj_field_name);
obj_field_name = NULL; obj_field_name = NULL;
saved_state = json_tokener_state_object_sep; saved_state = json_tokener_state_object_sep;


Loading…
Cancel
Save