From f7b0523425006afad63b3e87825a66bce5a5825b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 13 May 2019 10:02:42 +0200 Subject: [PATCH] Revert "BUG/MINOR: vars: Fix memory leak in vars_check_arg" This reverts commit 6ea00195c479d96c5aa651adcca3bc3637e3eceb. As found by Christopher, this fix is not correct due to the way args are built at various places. For example some config or runtime parsers will place a substring pointer there, and calling free() on it will immediately crash the program. A quick audit of the code shows that there are not that many users, but the way it's done requires to properly set the string as a regular chunk (size=0 if free not desired, then call chunk_destroy() at release time), and given that the size is currently set to len+1 in all parsers, a deeper audit needs to be done to figure the impacts of not setting it anymore. Thus for now better leave this harmless leak which impacts only the config parsing time. This fix must be backported to all branches containing the fix above. --- src/vars.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/vars.c b/src/vars.c index aa8bf185d9..477a146328 100644 --- a/src/vars.c +++ b/src/vars.c @@ -510,8 +510,6 @@ int vars_check_arg(struct arg *arg, char **err) err); if (!name) return 0; - free(arg->data.str.area); - arg->data.str.area = NULL; /* Use the global variable name pointer. */ arg->type = ARGT_VAR;