]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: pattern: Avoid memory leak on out-of-memory condition
authorAndreas Seltenreich <andreas.seltenreich@credativ.de>
Thu, 3 Mar 2016 19:20:23 +0000 (20:20 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 13 Mar 2016 06:47:25 +0000 (07:47 +0100)
pattern_new_expr() failed to free the allocated list element when an
out-of-memory error occurs during initialization of the element.  As
this only happens when loading the configuration file or evaluating
commands via the CLI, it is unlikely for this leak to be relevant
unless the user makes automated, heavy use of the CLI.

Found in HAProxy 1.5.14.

src/pattern.c

index 9d07b89c5a6beec96afce8a4b4880cb63094ed96..60fe462a105b1ecc212d0ce18966c0f2e21282bc 100644 (file)
@@ -2063,6 +2063,7 @@ struct pattern_expr *pattern_new_expr(struct pattern_head *head, struct pat_ref
                /* Get a lot of memory for the expr struct. */
                expr = malloc(sizeof(*expr));
                if (!expr) {
+                       free(list);
                        memprintf(err, "out of memory");
                        return NULL;
                }