From 5763a891a9b11961cad0cf6bae1ec079e0140d76 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sat, 19 Apr 2025 10:21:19 +0200 Subject: [PATCH] CLEANUP: proxy: detach the name node in proxy_free_common() instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changes commit d2a9149f0 ("BUG/MINOR: proxy: always detach a proxy from the names tree on free()") to be cleaner. Aurélien spotted that the free(p->id) was indeed already done in proxy_free_common(), which is called before we delete the node. That's still a bit ugly and it only works because ebpt_delete() does not dereference the key during the operation. Better play safe and delete the entry before freeing it, that's more future-proof. --- src/proxy.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/proxy.c b/src/proxy.c index 48090128d..8d87bf85c 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -213,6 +213,8 @@ static inline void proxy_free_common(struct proxy *px) struct lf_expr *lf, *lfb; struct eb32_node *node; + /* note that the node's key points to p->id */ + ebpt_delete(&px->conf.by_name); ha_free(&px->id); drop_file_name(&px->conf.file); ha_free(&px->check_command); @@ -414,10 +416,6 @@ void deinit_proxy(struct proxy *p) free(p->desc); - /* note that the node's key points to p->id */ - ebpt_delete(&p->conf.by_name); - free(p->id); - task_destroy(p->task); pool_destroy(p->req_cap_pool);