diff options
author | Tobias Stoeckmann <tobias@stoeckmann.org> | 2020-08-22 13:18:10 +0200 |
---|---|---|
committer | Tobias Stoeckmann <tobias@stoeckmann.org> | 2020-08-22 13:18:10 +0200 |
commit | bcb6d7d3474b687718cbaee7bf203db4456fb6b3 (patch) | |
tree | 00afc5c0a972046276085e352c3a79586eb3089d | |
parent | 2b439ea59857747067e8272011ad67303e0d4cf1 (diff) | |
download | json-c-bcb6d7d3474b687718cbaee7bf203db4456fb6b3.tar.gz |
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.
-rw-r--r-- | json_tokener.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/json_tokener.c b/json_tokener.c index 6527270..aad463a 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -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; |