Hi guys,
On Fri, May 16, 2014 at 11:34:45PM +0200, Thomas Heil wrote:
> >> So HAProxy crashes as soon as acl tries to use
> >> acl ex_de hdr_reg(host) -i www\.example\.de
> > Ok, so its probably about the modifications in src/pattern.c.
> No it was in
> #####
> -diff --git a/src/cfgparse.c b/src/cfgparse.c
> -index 9ec69a1..eb7ec20 100644
> ---- a/src/cfgparse.c
> -+++ b/src/cfgparse.c
> -@@ -1578,8 +1578,6 @@ static int create_cond_regex_rule(const char
> *file, int line,
> - if (dir == SMP_OPT_DIR_REQ && warnif_misplaced_reqxxx(px, file,
> line, cmd))
> - err_code |= ERR_WARN;
> -
> -- free(errmsg);
> -- return err_code;
> - err:
> - free(errmsg);
> - free(preg);
> #####
That's really strange, it looks like a double free or something like this!
Hmmm wait a minute, there's a bug here. preg is of type regex_t. It cannot be
freed with free(), but it needs a regfree() instead.
So it's likely that the move of free(errmsg) has slightly modified the code
path and helped the second free corrupt the memory better.
Thomas, could you please confirm that the attached patch (untested) fixes it
for you ? We might have a longstanding bug here.
Thanks,
Willy
diff --git a/src/cfgparse.c b/src/cfgparse.c
index fe39b22..0390024 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -1580,7 +1580,7 @@ static int create_cond_regex_rule(const char *file, int
line,
err:
free(errmsg);
- free(preg);
+ regfree(preg);
return err_code;
}