Fix buffer overflow (space for '\0' character missing)
This commit is contained in:
@@ -176,7 +176,7 @@ void initAlphabet(game_state *gs) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gs->alphabet = malloc(sizeof(char) * hasNumber ? ALPHABET : ALPHABET_NUM);
|
gs->alphabet = malloc(sizeof(char) * ((hasNumber ? ALPHABET : ALPHABET_NUM) + 1));
|
||||||
strcpy(gs->alphabet, "abcdefghijklmnopqrstuvwxyz");
|
strcpy(gs->alphabet, "abcdefghijklmnopqrstuvwxyz");
|
||||||
|
|
||||||
if (hasNumber) {
|
if (hasNumber) {
|
||||||
@@ -226,7 +226,7 @@ void drawGuessWord(game_state *gs) {
|
|||||||
}
|
}
|
||||||
rows++;
|
rows++;
|
||||||
}
|
}
|
||||||
gs->wordRows = rows; //set the number of rows for clearing the screen later
|
gs->wordRows = rows; //set the number of rows for clearing the screen later
|
||||||
tempstartpos = xcounter = gs->centerx - (gs->wordLength / rows);
|
tempstartpos = xcounter = gs->centerx - (gs->wordLength / rows);
|
||||||
}
|
}
|
||||||
for (i = startpos; i < startpos + (gs->wordLength * 2); i++) {
|
for (i = startpos; i < startpos + (gs->wordLength * 2); i++) {
|
||||||
|
Reference in New Issue
Block a user