pcre: fixes a memory leak on alloc error

pull/6434/head
Philippe Antoine 5 years ago
parent 8536048443
commit 8a50edbd10

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

Loading…
Cancel
Save