From 776dfc7b017ad307113ed9634de3adedcf61c28f Mon Sep 17 00:00:00 2001
From: Carl Worth <cworth@cworth.org>
Date: Sat, 14 Mar 2009 12:05:56 -0700
Subject: [PATCH] Fix memory leaks after calling readline.

We're responsible for cleaning up afterwards.
---
 mnemon.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/mnemon.c b/mnemon.c
index 4c5acd2..dfcc60e 100644
--- a/mnemon.c
+++ b/mnemon.c
@@ -1151,7 +1151,8 @@ mnemon_do_challenges (mnemon_t *mnemon)
 
 	while (1) {
 	    if (category->time_limit > 0.0) {
-		readline ("The next one is timed. Press enter when ready:");
+		response = readline ("The next one is timed. Press enter when ready:");
+		free (response);
 	    }
 		
 	    printf ("%s\n", item->challenge);
@@ -1166,10 +1167,12 @@ mnemon_do_challenges (mnemon_t *mnemon)
 		return;
 	    }
 
-	    if (response[0] == '/')
+	    if (response[0] == '/') {
 		mnemon_handle_command (mnemon, response + 1);
-	    else
+		free (response);
+	    } else {
 		break;
+	    }
 	}
 
 	mnemon_handle_response (mnemon, bin, item_index,
@@ -1177,6 +1180,7 @@ mnemon_do_challenges (mnemon_t *mnemon)
 				(end.tv_sec + end.tv_usec / 1e6) -
 				(start.tv_sec + start.tv_usec / 1e6),
 				category->time_limit);
+	free (response);
     } while (mnemon->to_introduce ||
 	     mnemon->unlearned ||
 	     mnemon->to_master > 0);
-- 
2.45.2