[BUG] acl: fd leak when reading patterns from file

The fd is not closed after patterns have successfully been read from
a file. Bug reported by Bertrand Jacquin. Should be backported to 1.4.
This commit is contained in:
Willy Tarreau 2011-02-26 15:14:15 +01:00
parent 9d9ed0113b
commit 6a8097f034

View File

@ -1059,6 +1059,7 @@ static int acl_read_patterns_from_file( struct acl_keyword *aclkw,
const char *args[2]; const char *args[2];
struct acl_pattern *pattern; struct acl_pattern *pattern;
int opaque; int opaque;
int ret = 0;
file = fopen(filename, "r"); file = fopen(filename, "r");
if (!file) if (!file)
@ -1119,15 +1120,14 @@ static int acl_read_patterns_from_file( struct acl_keyword *aclkw,
pattern = NULL; /* get a new one */ pattern = NULL; /* get a new one */
} }
} }
if (pattern)
free_pattern(pattern); ret = 1; /* success */
return 1;
out_free_pattern: out_free_pattern:
free_pattern(pattern); free_pattern(pattern);
out_close: out_close:
fclose(file); fclose(file);
return 0; return ret;
} }
/* Parse an ACL expression starting at <args>[0], and return it. /* Parse an ACL expression starting at <args>[0], and return it.