Fixed stack overrun when checking word.
authorPat Thoyts <patthoyts@users.sourceforge.net>
Mon, 21 Jun 2010 12:09:34 +0000 (13:09 +0100)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Mon, 21 Jun 2010 12:09:34 +0000 (13:09 +0100)
Also fixed a c99ism and removed the thumb files.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
i18n/en_GB/images/Thumbs.db [deleted file]
i18n/pt_BR/images/Thumbs.db [deleted file]
src/ag.c

diff --git a/i18n/en_GB/images/Thumbs.db b/i18n/en_GB/images/Thumbs.db
deleted file mode 100644 (file)
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 (file)
index 544f437..0000000
Binary files a/i18n/pt_BR/images/Thumbs.db and /dev/null differ
index 018a504c36c3e505437f8e28a37d950e4bfd182e..59eabf8b358e94ef35999ea2bfda27d2b3779884 100644 (file)
--- 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;
     }