From b4e625f074bb3c6acb5c16ff810a204694f0ed56 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 17 Oct 2019 12:03:37 +0200 Subject: [PATCH] mmkubernetes bugfix: improper use of calloc() could cause problems under extreme memory shortage - very unlikely credits to LGTM.COM for detecting this --- contrib/omhttp/omhttp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/omhttp/omhttp.c b/contrib/omhttp/omhttp.c index 3eff738f6..4baaaa53b 100644 --- a/contrib/omhttp/omhttp.c +++ b/contrib/omhttp/omhttp.c @@ -952,8 +952,9 @@ growCompressCtx(wrkrInstanceData_t *pWrkrData, size_t newLen) if (pWrkrData->compressCtx.buf == NULL) { CHKmalloc(pWrkrData->compressCtx.buf = (uchar *)malloc(sizeof(uchar)*newLen)); } else { - CHKmalloc(pWrkrData->compressCtx.buf = (uchar *)realloc(pWrkrData->compressCtx.buf, - sizeof(uchar)*newLen)); + uchar *const newbuf = (uchar *)realloc(pWrkrData->compressCtx.buf, sizeof(uchar)*newLen); + CHKmalloc(newbuf); + pWrkrData->compressCtx.buf = newbuf; } pWrkrData->compressCtx.len = newLen; finalize_it: