libc/regexp memory leak

Steve Mynott steve.mynott at gmail.com
Fri Jan 7 18:18:27 PST 2005


from FreeBSD http://www.freebsd.org/cgi/query-pr.cgi?pr=75656

--- /usr/src/lib/libc/regex/engine.c.orig       2005-01-08
01:49:14.000000000 +0000
+++ /usr/src/lib/libc/regex/engine.c    2005-01-08 01:49:42.000000000 +0000
@@ -239,6 +239,10 @@
        for (;;) {
                endp = fast(m, start, stop, gf, gl);
                if (endp == NULL) {             /* a miss */
+                       if (m->pmatch != NULL)
+                               free((char *)m->pmatch);
+                       if (m->lastpos != NULL)
+                               free((char *)m->lastpos);
                        STATETEARDOWN(m);
                        return(REG_NOMATCH);





More information about the Submit mailing list