]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
Revert "BUG/MINOR: vars: Fix memory leak in vars_check_arg"
authorWilly Tarreau <w@1wt.eu>
Mon, 13 May 2019 08:02:42 +0000 (10:02 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 May 2019 08:10:01 +0000 (10:10 +0200)
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

index aa8bf185d90bf5f5e78a29033eb785a265e78724..477a146328701c37a76c2d63ba26b483bf7e0a4c 100644 (file)
@@ -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;