Skip to content

Commit

Permalink
detect/http_header: fix leak on realloc failure
Browse files Browse the repository at this point in the history
  • Loading branch information
catenacyber authored and jasonish committed Feb 8, 2024
1 parent d3cc5d8 commit 922b262
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/detect-http-header.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] = ':';
Expand Down

0 comments on commit 922b262

Please sign in to comment.