Hello,

The following diff plugs a memory leak in regex lookups.

Cheers,


diff --git a/usr.sbin/smtpd/table.c b/usr.sbin/smtpd/table.c
index 469eeee1..d1578403 100644
--- a/usr.sbin/smtpd/table.c
+++ b/usr.sbin/smtpd/table.c
@@ -470,6 +470,7 @@ table_regex_match(const char *string, const char *pattern)
 {
        regex_t preg;
        int     cflags = REG_EXTENDED|REG_NOSUB;
+       int ret;
 
        if (strncmp(pattern, "(?i)", 4) == 0) {
                cflags |= REG_ICASE;
@@ -479,7 +480,11 @@ table_regex_match(const char *string, const char *pattern)
        if (regcomp(&preg, pattern, cflags) != 0)
                return (0);
 
-       if (regexec(&preg, string, 0, NULL, 0) != 0)
+       ret = regexec(&preg, string, 0, NULL, 0);
+
+       regfree(&preg);
+
+       if (ret != 0)
                return (0);
 
        return (1);

Reply via email to