]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] acl: fd leak when reading patterns from file
authorWilly Tarreau <w@1wt.eu>
Sat, 26 Feb 2011 14:14:15 +0000 (15:14 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 26 Feb 2011 14:14:15 +0000 (15:14 +0100)
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.

src/acl.c

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