]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http header: improve realloc failure checking. Bug #1062. 699/head
authorVictor Julien <victor@inliniac.net>
Mon, 9 Dec 2013 22:21:20 +0000 (23:21 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 9 Dec 2013 22:21:20 +0000 (23:21 +0100)
src/detect-engine-hhd.c

index 8bdc6acedb4a4e076ceea7c7ff07e7c4a1d22e5f..759c826a022ad3a11dc5449ccf2598b8bac9fc7a 100644 (file)
@@ -156,12 +156,15 @@ static uint8_t *DetectEngineHHDGetBufferForTX(htp_tx_t *tx, uint64_t tx_id,
         }
 
         /* the extra 4 bytes if for ": " and "\r\n" */
-        headers_buffer = SCRealloc(headers_buffer, headers_buffer_len + size1 + size2 + 4);
-        if (unlikely(headers_buffer == NULL)) {
+        uint8_t *new_headers_buffer = SCRealloc(headers_buffer, headers_buffer_len + size1 + size2 + 4);
+        if (unlikely(new_headers_buffer == NULL)) {
+            if (headers_buffer != NULL)
+                SCFree(headers_buffer);
             det_ctx->hhd_buffers[index] = NULL;
             det_ctx->hhd_buffers_len[index] = 0;
             goto end;
         }
+        headers_buffer = new_headers_buffer;
 
         memcpy(headers_buffer + headers_buffer_len, bstr_ptr(h->name), size1);
         headers_buffer_len += size1;