]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cli: use srv_drop() when server was created using new_server()
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 13 Jan 2026 18:37:54 +0000 (19:37 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Mon, 19 Jan 2026 13:23:58 +0000 (14:23 +0100)
Now that new_server() is becoming more and more complex, we need to
take care that servers created using new_server() must be released
using the corresponding release function srv_drop() which takes care
of properly de-initing the server and its members.

src/cli.c
src/server.c

index 09494c718e38c20b49b91b51b7541315c5d9d3ae..ebf47cea709521866ea0ad6d990083f52a08e457 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -3737,11 +3737,8 @@ int mworker_cli_attach_server(char **errmsg)
 
 error:
 
-       list_for_each_entry(child, &proc_list, list) {
-               free((char *)child->srv->conf.file); /* cast because of const char *  */
-               free(child->srv->id);
-               srv_free(&child->srv);
-       }
+       list_for_each_entry(child, &proc_list, list)
+               srv_drop(child->srv);
        free(msg);
 
        return -1;
index 024b032444d88dc06bac6ef38d70b3bd48cb8900..a86047fdfc6ed83841c89f0846db611c84176486 100644 (file)
@@ -3434,7 +3434,7 @@ static int _srv_parse_tmpl_init(struct server *srv, struct proxy *px)
                free_check(&newsrv->check);
                MT_LIST_DELETE(&newsrv->global_list);
        }
-       srv_free(&newsrv);
+       srv_drop(newsrv);
        return i - srv->tmpl_info.nb_low;
 }