1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-05-28 05:07:50 +02:00

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.
This commit is contained in:
Jim Meyering
2007-01-11 19:31:27 +01:00
parent c6357f0cab
commit 4e2fd4cca6
2 changed files with 16 additions and 1 deletions
+5
View File
@@ -1,5 +1,10 @@
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.
+11 -1
View File
@@ -427,6 +427,10 @@ docolon (VALUE *sv, VALUE *pv)
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;
@@ -463,7 +467,13 @@ docolon (VALUE *sv, VALUE *pv)
(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;
}