* src/expr.c (docolon): Free the regexp buffer using regfree, rather
than doing it manually, being careful to set fastmap to NULL first.
Free any re_regs.start and .end members, if necessary.
2007-01-11 Jim Meyering <jim@meyering.net>
+ Avoid a leak in expr's implementation of the ":" (match) operator.
+ * src/expr.c (docolon): Free the regexp buffer using regfree, rather
+ than doing it manually, being careful to set fastmap to NULL first.
+ Free any re_regs.start and .end members, if necessary.
+
* tests/misc/test-diag: Work also when libc's error function
reports the entire program name ("../../src/test"), rather than
just the final component.
tostring (sv);
tostring (pv);
+ re_regs.num_regs = 0;
+ re_regs.start = NULL;
+ re_regs.end = NULL;
+
re_buffer.buffer = NULL;
re_buffer.allocated = 0;
re_buffer.fastmap = fastmap;
(matchlen == -2 ? errno : EOVERFLOW),
_("error in regular expression matcher"));
- free (re_buffer.buffer);
+ if (0 < re_regs.num_regs)
+ {
+ free (re_regs.start);
+ free (re_regs.end);
+ }
+ re_buffer.fastmap = NULL;
+ regfree (&re_buffer);
return v;
}