MINOR: regex: fix a little configuration memory leak.
The function regfree free the memory allocated to the pattern buffer by
the compiling process. It is not freeing the buffer itself.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 017bcae..eb40833 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -2118,7 +2118,11 @@
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 @@
}
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 @@
}
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) {