From: Willy Tarreau Date: Tue, 5 Aug 2025 16:46:34 +0000 (+0200) Subject: MINOR: pools: add a new flag to declare static registrations X-Git-Tag: v3.3-dev6~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ee5bc28865eee7fe68c86af4b70ef75012471fc6;p=thirdparty%2Fhaproxy.git MINOR: pools: add a new flag to declare static registrations We must not free these ones when destroying a pool, so let's dedicate them a flag to mention that they are static. For now we don't have any such. --- diff --git a/include/haproxy/pool-t.h b/include/haproxy/pool-t.h index 1801f135b..524c871b8 100644 --- a/include/haproxy/pool-t.h +++ b/include/haproxy/pool-t.h @@ -28,6 +28,7 @@ #define MEM_F_SHARED 0x1 #define MEM_F_EXACT 0x2 #define MEM_F_UAF 0x4 +#define MEM_F_STATREG 0x8 /* static registration: do not free it! */ /* A special pointer for the pool's free_list that indicates someone is * currently manipulating it. Serves as a short-lived lock. diff --git a/src/pool.c b/src/pool.c index 159a28a1b..43359403f 100644 --- a/src/pool.c +++ b/src/pool.c @@ -1049,7 +1049,8 @@ void *pool_destroy(struct pool_head *pool) list_for_each_entry_safe(reg, back, &pool->regs, list) { LIST_DELETE(®->list); - free(reg); + if (!(reg->flags & MEM_F_STATREG)) + free(reg); } LIST_DELETE(&pool->list);