]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: regex: fix a little configuration memory leak.
authorThierry FOURNIER <tfournier@exceliance.fr>
Wed, 11 Jun 2014 12:45:31 +0000 (14:45 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 16 Jun 2014 14:47:20 +0000 (16:47 +0200)
The function regfree free the memory allocated to the pattern buffer by
the compiling process. It is not freeing the buffer itself.

src/cfgparse.c

index 017bcae029ce17c381cac2c0d2fe2cb3fcb508ee..eb4083374253bb9a9b1287c0d09fc1f0a1af57c3 100644 (file)
@@ -2118,7 +2118,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                free(defproxy.server_id_hdr_name);
                defproxy.server_id_hdr_len = 0;
                free(defproxy.expect_str);
-               if (defproxy.expect_regex) regfree(defproxy.expect_regex);
+               if (defproxy.expect_regex) {
+                       regfree(defproxy.expect_regex);
+                       free(defproxy.expect_regex);
+                       defproxy.expect_regex = NULL;
+               }
 
                if (defproxy.conf.logformat_string != default_http_log_format &&
                    defproxy.conf.logformat_string != default_tcp_log_format &&
@@ -4208,7 +4212,11 @@ stats_error_parsing:
                                }
                                curproxy->options2 |= PR_O2_EXP_RSTS;
                                free(curproxy->expect_str);
-                               if (curproxy->expect_regex) regfree(curproxy->expect_regex);
+                               if (curproxy->expect_regex) {
+                                       regfree(curproxy->expect_regex);
+                                       free(curproxy->expect_regex);
+                                       curproxy->expect_regex = NULL;
+                               }
                                curproxy->expect_str = strdup(args[cur_arg + 1]);
                                curproxy->expect_regex = calloc(1, sizeof(regex_t));
                                if (regcomp(curproxy->expect_regex, args[cur_arg + 1], REG_EXTENDED) != 0) {
@@ -4227,7 +4235,11 @@ stats_error_parsing:
                                }
                                curproxy->options2 |= PR_O2_EXP_RSTR;
                                free(curproxy->expect_str);
-                               if (curproxy->expect_regex) regfree(curproxy->expect_regex);
+                               if (curproxy->expect_regex) {
+                                       regfree(curproxy->expect_regex);
+                                       free(curproxy->expect_regex);
+                                       curproxy->expect_regex = NULL;
+                               }
                                curproxy->expect_str = strdup(args[cur_arg + 1]);
                                curproxy->expect_regex = calloc(1, sizeof(regex_t));
                                if (regcomp(curproxy->expect_regex, args[cur_arg + 1], REG_EXTENDED) != 0) {