From 0c39a7e8f0393d0c97cbecca10590afce51abb8f Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 18 Jun 2019 19:45:30 +0200 Subject: [PATCH] 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. --- tfortune.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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(); -- 2.39.2