]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/http_header: fix leak on realloc failure
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 8 Feb 2024 19:23:59 +0000 (20:23 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 9 Feb 2024 10:24:04 +0000 (11:24 +0100)
src/detect-http-header.c

index 7c15bf094a765607ce7060dc2a27a1e081c2483e..e32220576ba118c1de55d965a59493e63b40a088 100644 (file)
@@ -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] = ':';