From: Jeff Lucovsky Date: Wed, 31 Jul 2024 14:24:33 +0000 (-0400) Subject: output/json: Close jb object on error X-Git-Tag: suricata-7.0.7~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3af0e98a1873f451dd0d145061f54fd10bdf77b;p=thirdparty%2Fsuricata.git output/json: Close jb object on error Issue: 7194 Ensure that the jb object is closed on errors. --- diff --git a/src/output-json.c b/src/output-json.c index 7c3b7e2757..6e5ff238d7 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -445,7 +445,13 @@ void EvePacket(const Packet *p, JsonBuilder *js, unsigned long max_length) if (!jb_open_object(js, "packet_info")) { return; } + /* + * ensure the object is closed on error. This is done defensively + * in case additional logic is added before the final jb_close() + * invocation + */ if (!jb_set_uint(js, "linktype", p->datalink)) { + jb_close(js); return; } jb_close(js);