From 5f1d84868d445ede36dc93a3ad7c574c8c149b04 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Tue, 16 Jan 2018 12:32:16 +0200 Subject: [PATCH] Fix a memleak. --- fortune-mod/fortune/fortune.c | 4 ++++ fortune-mod/tests/t/valgrind.t | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/fortune-mod/fortune/fortune.c b/fortune-mod/fortune/fortune.c index 2c624cd..1239908 100644 --- a/fortune-mod/fortune/fortune.c +++ b/fortune-mod/fortune/fortune.c @@ -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 */ } diff --git a/fortune-mod/tests/t/valgrind.t b/fortune-mod/tests/t/valgrind.t index bd25ad3..3e4212b 100644 --- a/fortune-mod/tests/t/valgrind.t +++ b/fortune-mod/tests/t/valgrind.t @@ -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', + } +); -- 2.40.0