BUG/MINOR: pattern: Avoid memory leak on out-of-memory condition

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.
This commit is contained in:
Andreas Seltenreich 2016-03-03 20:20:23 +01:00 committed by Willy Tarreau
parent 93f91c3082
commit e6e22e8e90

View 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;
}