]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output/json: Close jb object on error
authorJeff Lucovsky <jlucovsky@oisf.net>
Wed, 31 Jul 2024 14:24:33 +0000 (10:24 -0400)
committerVictor Julien <victor@inliniac.net>
Wed, 7 Aug 2024 06:31:25 +0000 (08:31 +0200)
Issue: 7194

Ensure that the jb object is closed on errors.

src/output-json.c

index 7c3b7e27579cc9c4852e0e594b17a9c824629f43..6e5ff238d7a586c312d27a24d75373a5f2c5a7a0 100644 (file)
@@ -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);