From: Willy Tarreau Date: Thu, 22 May 2025 16:09:12 +0000 (+0200) Subject: BUG/MEDIUM: server: fix potential null-deref after previous fix X-Git-Tag: v3.0.11~14 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=301898097c003a386f29e3f9b7d3b624b1c91608;p=haproxy-3.0.git BUG/MEDIUM: server: fix potential null-deref after previous fix A valid build warning was reported in the CI with latest commit b40ce97ecc ("BUG/MEDIUM: server: fix crash after duplicate GUID insertion"). Indeed, if the first test in the function fails, we branch to the err label with guid==NULL and will crash there. Let's just test guid before dereferencing it for freeing. This needs to be backported to 3.0 as well since the commit above was meant to go there. (cherry picked from commit 28c7a22790a587c6a3ee1652188ad6786d59b687) Signed-off-by: Christopher Faulet (cherry picked from commit d883c7113fc28d48468c4cc5dc0a27ad3b122497) Signed-off-by: Christopher Faulet --- diff --git a/src/guid.c b/src/guid.c index f2bc99c..01f52c1 100644 --- a/src/guid.c +++ b/src/guid.c @@ -75,7 +75,8 @@ int guid_insert(enum obj_type *objt, const char *uid, char **errmsg) return 0; err: - ha_free(&guid->node.key); + if (guid) + ha_free(&guid->node.key); ha_free(&dup_name); return 1; }