From: Christopher Faulet Date: Mon, 2 Oct 2023 16:54:29 +0000 (+0200) Subject: BUILD: pool: Fix GCC error about potential null pointer dereference X-Git-Tag: v2.9-dev7~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b62d5689d2a1cc774414a28c42e939af146a78d4;p=thirdparty%2Fhaproxy.git BUILD: pool: Fix GCC error about potential null pointer dereference In pool_gc(), GCC 13.2.1 reports an error about a potential null potential dereference: src/pool.c: In function ‘pool_gc’: src/pool.c:807:64: error: potential null pointer dereference [-Werror=null-dereference] 807 | entry->buckets[bucket].free_list = temp->next; | ~~~~^~~~~~ There is no issue here because "bucket" variable cannot be greater than CONFIG_HAP_POOL_BUCKETS. But to make GCC happy, we now break the loop if it is greater or equal to CONFIG_HAP_POOL_BUCKETS. --- diff --git a/src/pool.c b/src/pool.c index 2f20fd5553..964421fee6 100644 --- a/src/pool.c +++ b/src/pool.c @@ -800,7 +800,7 @@ void pool_gc(struct pool_head *pool_ctx) while (!entry->buckets[bucket].free_list && bucket < CONFIG_HAP_POOL_BUCKETS) bucket++; - if (bucket == CONFIG_HAP_POOL_BUCKETS) + if (bucket >= CONFIG_HAP_POOL_BUCKETS) break; temp = entry->buckets[bucket].free_list;