From: Willy Tarreau Date: Sun, 14 Jun 2020 05:50:18 +0000 (+0200) Subject: BUILD: compression: make gcc 10 happy with free_zlib() X-Git-Tag: v2.2-dev10~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d999a496639465e809b1c053d3c1ae18e72345d4;p=thirdparty%2Fhaproxy.git BUILD: compression: make gcc 10 happy with free_zlib() In issue #685 gcc 10 seems to find a null pointer deref in free_zlib(). There is no such case because all possible pools are tested and there's no other one in zlib, except if there's a bug or memory corruption somewhere else. The code used to be written like this to make sure that any such bug couldn't remain unnoticed. Now gcc 10 sees this theorical code path and complains, so let's just change the code to place an explicit crash in case of no match (which must never happen). This might be backported if other versions are affected. --- diff --git a/src/compression.c b/src/compression.c index ffe5b0b04a..e3f34b5654 100644 --- a/src/compression.c +++ b/src/compression.c @@ -490,6 +490,11 @@ static void free_zlib(void *opaque, void *ptr) pool = zlib_pool_head; else if (ptr == ctx->zlib_pending_buf) pool = zlib_pool_pending_buf; + else { + // never matched, just to silence gcc + ABORT_NOW(); + return; + } pool_free(pool, ptr); _HA_ATOMIC_SUB(&zlib_used_memory, pool->size);