]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/pcre: fix error handling
authorEric Leblond <el@stamus-networks.com>
Mon, 9 Jun 2025 09:14:37 +0000 (11:14 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 11 Jun 2025 18:49:19 +0000 (20:49 +0200)
src/detect-pcre.c

index a3520e6305e6da668c167bce4e7fab19ccceccf3..df364902c1a459490d2398e98baee264ab616a62 100644 (file)
@@ -180,6 +180,13 @@ static void DetectAlertStoreMatch(DetectEngineThreadCtx *det_ctx, const Signatur
         if (js_len > SIG_JSON_CONTENT_ITEM_LEN) {
             SCLogDebug("Captured length is too long for JSON.");
             SCFree(str_ptr);
+            SCJbFree(js);
+            return;
+        }
+        if (js_len == 0) {
+            SCLogDebug("Captured length is zero for JSON.");
+            SCFree(str_ptr);
+            SCJbFree(js);
             return;
         }
         /* Copy js but skip the starting curly bracket to just get the inner data */