From 65e2e472dd604e93d566206c2267738767ca726b Mon Sep 17 00:00:00 2001 From: "Jason S. Ninneman" Date: Sun, 18 Jun 2017 14:14:13 -0700 Subject: [PATCH] Fix bug that made YES() case-sensitive. Also fix a related memory leak. --- misc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/misc.c b/misc.c index aa4286b..fc7ac5f 100644 --- a/misc.c +++ b/misc.c @@ -271,10 +271,12 @@ bool YES(vocab_t question, vocab_t yes_response, vocab_t no_response) for (int i = 0; i < strlen(firstword); ++i) firstword[i] = tolower(firstword[i]); - int yes = strncmp("yes", reply, sizeof("yes") - 1); - int y = strncmp("y", reply, sizeof("y") - 1); - int no = strncmp("no", reply, sizeof("no") - 1); - int n = strncmp("n", reply, sizeof("n") - 1); + int yes = strncmp("yes", firstword, sizeof("yes") - 1); + int y = strncmp("y", firstword, sizeof("y") - 1); + int no = strncmp("no", firstword, sizeof("no") - 1); + int n = strncmp("n", firstword, sizeof("n") - 1); + + free(firstword); if (yes == 0 || y == 0) { RSPEAK(yes_response); -- 2.31.1