]> granicus.if.org Git - fortune-mod/commitdiff
Fix a memleak.
authorShlomi Fish <shlomif@shlomifish.org>
Tue, 16 Jan 2018 10:32:16 +0000 (12:32 +0200)
committerShlomi Fish <shlomif@shlomifish.org>
Tue, 16 Jan 2018 10:32:16 +0000 (12:32 +0200)
fortune-mod/fortune/fortune.c
fortune-mod/tests/t/valgrind.t

index 2c624cd36b6432d455fe6b8ed57191ee63431c67..12399085125505f3b1ec74c6be3ee64686757235 100644 (file)
@@ -1103,6 +1103,10 @@ static void getargs(int argc, char **argv)
             fprintf(stderr, "bad pattern: %s\n", pat);
             exit (1);
         }
+        if (ignore_case)
+        {
+            free(pat);
+        }
     }
 #endif /* NO_REGEX */
 }
index bd25ad38aa114756bd7663382ac1df541aade566..3e4212b79a37114f3d27615647593fdab297d128 100644 (file)
@@ -7,7 +7,7 @@ use Test::More;
 use Test::RunValgrind;
 
 # plan skip_all => 'lib-recode has memory leaks';
-plan tests => 3;
+plan tests => 4;
 
 my $obj = Test::RunValgrind->new({});
 
@@ -40,3 +40,13 @@ $obj->run(
         blurb => 'fortune -m valgrind test',
     }
 );
+
+# TEST
+$obj->run(
+    {
+        log_fn => './fortune--4-dash-m-i.valgrind-log',
+        prog => './fortune',
+        argv => [qw/-i -m foobarbazINGAMINGATONGALKIYRE/],
+        blurb => 'fortune -i -m valgrind test',
+    }
+);