mirror of
https://github.com/json-c/json-c.git
synced 2026-04-09 07:19:06 +08:00
Handle NULL gracefully in json_tokener_free
Similarly to glibc's free, make json_tokener_free(NULL) a no-op, to simplify cleanup paths. Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
@@ -182,6 +182,8 @@ struct json_tokener *json_tokener_new(void)
|
|||||||
|
|
||||||
void json_tokener_free(struct json_tokener *tok)
|
void json_tokener_free(struct json_tokener *tok)
|
||||||
{
|
{
|
||||||
|
if (!tok)
|
||||||
|
return;
|
||||||
json_tokener_reset(tok);
|
json_tokener_reset(tok);
|
||||||
if (tok->pb)
|
if (tok->pb)
|
||||||
printbuf_free(tok->pb);
|
printbuf_free(tok->pb);
|
||||||
|
|||||||
Reference in New Issue
Block a user