]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: pool: Fix GCC error about potential null pointer dereference
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 2 Oct 2023 16:54:29 +0000 (18:54 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 4 Oct 2023 06:03:02 +0000 (08:03 +0200)
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.

src/pool.c

index 2f20fd55537ed9c9f7328e177f9831ca5631405c..964421fee6358b086715097b7ce14e12dfa74f29 100644 (file)
@@ -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;