From 828c12b22661de53d6497bd1410c68cb153b4f35 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Tomko?= Date: Wed, 6 Nov 2024 15:19:04 +0100 Subject: [PATCH] Handle NULL gracefully in json_tokener_free MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Similarly to glibc's free, make json_tokener_free(NULL) a no-op, to simplify cleanup paths. Signed-off-by: Ján Tomko --- json_tokener.c | 2 ++ 1 file changed, 2 insertions(+) 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); -- 2.39.5