Browse Source

Handle allocation failure in json_tokener_new_ex

The allocation of printbuf_new might fail. Return NULL to indicate tis
error to the caller. Otherwise later usage of the returned tokener would
lead to null pointer dereference.
tags/json-c-0.16-20220414
Tobias Stoeckmann 5 years ago
parent
commit
bcb6d7d347
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      json_tokener.c

+ 6
- 0
json_tokener.c View File

@@ -134,6 +134,12 @@ struct json_tokener *json_tokener_new_ex(int depth)
return NULL;
}
tok->pb = printbuf_new();
if (!tok->pb)
{
free(tok);
free(tok->stack);
return NULL;
}
tok->max_depth = depth;
json_tokener_reset(tok);
return tok;


Loading…
Cancel
Save