From: Philippe Antoine Date: Fri, 1 Oct 2021 13:55:19 +0000 (+0200) Subject: pcre: fixes a memory leak on alloc error X-Git-Tag: suricata-7.0.0-beta1~1311 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a50edbd101bbdbde92b89eef8d7fb1cf6c359c3;p=thirdparty%2Fsuricata.git pcre: fixes a memory leak on alloc error --- diff --git a/src/detect-pcre.c b/src/detect-pcre.c index bb70a70cd5..24ade21a88 100644 --- a/src/detect-pcre.c +++ b/src/detect-pcre.c @@ -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);