com_stats(): Fix memory leak.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 18 Jun 2019 17:45:30 +0000 (19:45 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 19 Jun 2019 09:33:08 +0000 (11:33 +0200)
We currently leak one allocation per tag. Not a big deal since
"stats" is a short-running subcommand. But at least valgrind no
longer complains.

tfortune.c

index 724b8ba..02e54ea 100644 (file)
@@ -871,8 +871,10 @@ static int com_stats(void)
                liter = linhash_iterator_new(tagtab, NULL, false);
                (itemp = linhash_iterator_item(liter));
                linhash_iterator_next(liter)
-       )
+       ) {
+               free((char *)itemp->key);
                num_tags += (long unsigned)itemp->object;
+       }
        num_unique_tags = linhash_num_items(tagtab);
        linhash_iterator_free(liter);
        xdir = get_xdir();