]> 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)
committerShivani Bhardwaj <shivanib134@gmail.com>
Fri, 9 Feb 2024 14:11:39 +0000 (19:41 +0530)
(cherry picked from commit b48ec8a03922f36e76f2d6d942f2963afc2a3345)

src/detect-http-header.c

index 0d4b3d6e52b5712ed6f5bde7bdd282ce91c59e74..8a7838042821a25a2b7dd3276d9dfbbdc365e790 100644 (file)
@@ -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] = ':';