]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
pcre: fixes a memory leak on alloc error
authorPhilippe Antoine <contact@catenacyber.fr>
Fri, 1 Oct 2021 13:55:19 +0000 (15:55 +0200)
committerPhilippe Antoine <contact@catenacyber.fr>
Fri, 1 Oct 2021 13:55:19 +0000 (15:55 +0200)
src/detect-pcre.c

index bb70a70cd5e19cbe3dbe79b223299daceab345f1..24ade21a88ed4a1708e7fbb74313268329f2bcfa 100644 (file)
@@ -266,8 +266,9 @@ int DetectPcrePayloadMatch(DetectEngineThreadCtx *det_ctx, const Signature *s,
                         capture_len = (capture_len < 0xffff) ? (uint16_t)capture_len : 0xffff;
                         uint8_t *str_ptr2 = SCMalloc(capture_len);
                         if (unlikely(str_ptr2 == NULL)) {
-                            pcre2_substring_free((PCRE2_UCHAR8 *)pcre2_str_ptr);
-                            continue;
+                            SCFree(str_ptr);
+                            pcre2_substring_free((PCRE2_UCHAR8 *)pcre2_str_ptr2);
+                            break;
                         }
                         memcpy(str_ptr2, pcre2_str_ptr2, capture_len);
                         pcre2_substring_free((PCRE2_UCHAR8 *)pcre2_str_ptr2);