From: Andre Noll Date: Tue, 18 Jun 2019 17:45:30 +0000 (+0200) Subject: com_stats(): Fix memory leak. X-Git-Tag: v1.0.1~4 X-Git-Url: http://git.tuebingen.mpg.de/?p=tfortune.git;a=commitdiff_plain;h=0c39a7e8f0393d0c97cbecca10590afce51abb8f com_stats(): Fix memory leak. 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. --- diff --git a/tfortune.c b/tfortune.c index 724b8ba..02e54ea 100644 --- a/tfortune.c +++ b/tfortune.c @@ -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();