From a146289d4f3b9940f20ae1640b26fa939761224b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sat, 16 Oct 2021 14:45:29 +0200 Subject: [PATCH] BUG/MINOR: listener: fix incorrect return on out-of-memory When the clone_listener() function was added in commit 59a877dfd ("MINOR: listeners: add clone_listener() to duplicate listeners at boot time"), a stupid bug was introduced when splitting the error path because while the first case where calloc fails will leave NULL in the output value, the other cases will return the pointer to a freed area. This was reported by Coverity in issue #1416. In practice nobody will face it (out-of-memory while checking config), but let's fix it. No backport is needed. --- src/listener.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/listener.c b/src/listener.c index f16ba2d0a..5c2eb210a 100644 --- a/src/listener.c +++ b/src/listener.c @@ -709,7 +709,7 @@ struct listener *clone_listener(struct listener *src) oom2: free(l); oom1: - return l; + return NULL; } /* Delete a listener from its protocol's list of listeners. The listener's