From: Philippe Antoine Date: Thu, 8 Feb 2024 19:23:59 +0000 (+0100) Subject: detect/http_header: fix leak on realloc failure X-Git-Tag: suricata-8.0.0-beta1~1785 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b48ec8a03922f36e76f2d6d942f2963afc2a3345;p=thirdparty%2Fsuricata.git detect/http_header: fix leak on realloc failure --- diff --git a/src/detect-http-header.c b/src/detect-http-header.c index 7c15bf094a..e32220576b 100644 --- a/src/detect-http-header.c +++ b/src/detect-http-header.c @@ -663,10 +663,11 @@ static InspectionBuffer *GetHttp1HeaderData(DetectEngineThreadCtx *det_ctx, cons size_t size = size1 + size2 + 2; if (hdr_td->items[i].len < size) { // Use realloc, as this pointer is not freed until HttpMultiBufHeaderThreadDataFree - hdr_td->items[i].buffer = SCRealloc(hdr_td->items[i].buffer, size); - if (unlikely(hdr_td->items[i].buffer == NULL)) { + void *tmp = SCRealloc(hdr_td->items[i].buffer, size); + if (unlikely(tmp == NULL)) { return NULL; } + hdr_td->items[i].buffer = tmp; } memcpy(hdr_td->items[i].buffer, bstr_ptr(h->name), size1); hdr_td->items[i].buffer[size1] = ':';