From: Ján Tomko Date: Wed, 6 Nov 2024 14:19:04 +0000 (+0100) Subject: Handle NULL gracefully in json_tokener_free X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F879%2Fhead;p=thirdparty%2Fjson-c.git 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 --- diff --git a/json_tokener.c b/json_tokener.c index c831f8a..4453c89 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -182,6 +182,8 @@ struct json_tokener *json_tokener_new(void) void json_tokener_free(struct json_tokener *tok) { + if (!tok) + return; json_tokener_reset(tok); if (tok->pb) printbuf_free(tok->pb);