From: Pat Thoyts Date: Mon, 21 Jun 2010 12:09:34 +0000 (+0100) Subject: Fixed stack overrun when checking word. X-Git-Tag: v0.4~9 X-Git-Url: https://privyetmir.co.uk/gitweb.cgi?a=commitdiff_plain;h=d6536d98bd1f3467fcaf8d1abc834527a8150566;p=anagramarama Fixed stack overrun when checking word. Also fixed a c99ism and removed the thumb files. Signed-off-by: Pat Thoyts --- diff --git a/i18n/en_GB/images/Thumbs.db b/i18n/en_GB/images/Thumbs.db deleted file mode 100644 index 599a80b..0000000 Binary files a/i18n/en_GB/images/Thumbs.db and /dev/null differ diff --git a/i18n/pt_BR/images/Thumbs.db b/i18n/pt_BR/images/Thumbs.db deleted file mode 100644 index 544f437..0000000 Binary files a/i18n/pt_BR/images/Thumbs.db and /dev/null differ diff --git a/src/ag.c b/src/ag.c index 018a504..59eabf8 100644 --- a/src/ag.c +++ b/src/ag.c @@ -514,13 +514,13 @@ checkGuess(char* answer, struct node* head) int foundWord = 0; char test[8]; + memset(test, 0, sizeof(test)); len = nextBlank(answer) - 1; - if (len == -1) len = 8; + if (len == -1) len = sizeof(test); for (i = 0; i < len; i++) { assert(i < sizeof(test)); test[i] = answer[i]; } - test[len] = '\0'; #ifdef DEBUG printf("check guess len:%d answer:'%s' test:'%s'\n", len, answer, test); #endif @@ -532,7 +532,7 @@ checkGuess(char* answer, struct node* head) score += current->length; totalScore += current->length; answersGot++; - if (len == bigWordLen) { + if (len-1 == bigWordLen) { gotBigWord = 1; Mix_PlayChannel(-1, getSound("foundbig"), 0); } else { @@ -988,12 +988,13 @@ outputs: n/a static void shuffleWord(char *word) { + char tmp; int a, b, n; int count = (rand() % 7) + 20; for (n = 0; n < count; ++n) { a = rand() % 7; b = rand() % 7; - char tmp = word[a]; + tmp = word[a]; word[a] = word[b]; word[b] = tmp; }