]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: arg: don't try to add an argument on failed memory allocation
authorWilly Tarreau <w@1wt.eu>
Wed, 12 Apr 2017 20:28:52 +0000 (22:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Apr 2017 21:23:43 +0000 (23:23 +0200)
Take care of arg_list_clone() returning NULL in arg_list_add() since
the former does it too. It's only used during parsing so the impact
is very low.

Can be backported to 1.7, 1.6 and 1.5.

src/arg.c

index 9e551fb8e0845e880342ea6e415b8264be8e7b8b..ca914faa9ca4fb9208cb1c5d3cf521e020cb7a38 100644 (file)
--- a/src/arg.c
+++ b/src/arg.c
@@ -72,9 +72,11 @@ struct arg_list *arg_list_add(struct arg_list *orig, struct arg *arg, int pos)
        struct arg_list *new;
 
        new = arg_list_clone(orig);
-       new->arg = arg;
-       new->arg_pos = pos;
-       LIST_ADDQ(&orig->list, &new->list);
+       if (new) {
+               new->arg = arg;
+               new->arg_pos = pos;
+               LIST_ADDQ(&orig->list, &new->list);
+       }
        return new;
 }