From: Victor Julien Date: Mon, 9 Dec 2013 22:21:20 +0000 (+0100) Subject: http header: improve realloc failure checking. Bug #1062. X-Git-Tag: suricata-2.0beta2~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F699%2Fhead;p=thirdparty%2Fsuricata.git http header: improve realloc failure checking. Bug #1062. --- diff --git a/src/detect-engine-hhd.c b/src/detect-engine-hhd.c index 8bdc6acedb..759c826a02 100644 --- a/src/detect-engine-hhd.c +++ b/src/detect-engine-hhd.c @@ -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;