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-7.0.4~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d69ed953403c3f60ee240cdbe86247b2ef48ffd;p=thirdparty%2Fsuricata.git detect/http_header: fix leak on realloc failure (cherry picked from commit b48ec8a03922f36e76f2d6d942f2963afc2a3345) --- diff --git a/src/detect-http-header.c b/src/detect-http-header.c index 0d4b3d6e52..8a78380428 100644 --- a/src/detect-http-header.c +++ b/src/detect-http-header.c @@ -673,10 +673,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] = ':';