commit 5705be4c622af4a4027a711c5dbbb42d9ce0ea8a
Author: Simon Howard <fraggle@soulsphere.org>
AuthorDate: Sat Nov 3 12:37:00 2018 -0400
Commit: Simon Howard <fraggle@soulsphere.org>
CommitDate: Sat Nov 3 12:37:00 2018 -0400
doom: Bump tempstring[] size to 90 bytes.
tempstring[] is currently 80 bytes which means that the quickload
message gets truncated for long savegame names. I believe this was
always an issue (even in Vanilla?) but recent changes to use safe
string functions (commit 040ca1cfb5a3e1be7) surfaced the bug.
This fixes #1069.
---
src/doom/m_menu.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c
index 37b6547c..135679eb 100644
--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -691,7 +691,7 @@ void M_SaveGame (int choice)
//
// M_QuickSave
//
-char tempstring[80];
+static char tempstring[90];
void M_QuickSaveResponse(int key)
{
@@ -721,8 +721,9 @@ void M_QuickSave(void)
quickSaveSlot = -2; // means to pick a slot now
return;
}
- DEH_snprintf(tempstring, 80, QSPROMPT, savegamestrings[quickSaveSlot]);
- M_StartMessage(tempstring,M_QuickSaveResponse,true);
+ DEH_snprintf(tempstring, sizeof(tempstring),
+ QSPROMPT, savegamestrings[quickSaveSlot]);
+ M_StartMessage(tempstring, M_QuickSaveResponse, true);
}
@@ -753,8 +754,9 @@ void M_QuickLoad(void)
M_StartMessage(DEH_String(QSAVESPOT),NULL,false);
return;
}
- DEH_snprintf(tempstring, 80, QLPROMPT, savegamestrings[quickSaveSlot]);
- M_StartMessage(tempstring,M_QuickLoadResponse,true);
+ DEH_snprintf(tempstring, sizeof(tempstring),
+ QLPROMPT, savegamestrings[quickSaveSlot]);
+ M_StartMessage(tempstring, M_QuickLoadResponse, true);
}
@@ -1930,9 +1932,9 @@ void M_Drawer (void)
y = SCREENHEIGHT/2 - M_StringHeight(messageString) / 2;
while (messageString[start] != '\0')
{
- int foundnewline = 0;
+ boolean foundnewline = false;
- for (i = 0; i < strlen(messageString + start); i++)
+ for (i = 0; messageString[start + i] != '\0'; i++)
{
if (messageString[start + i] == '\n')
{
@@ -1943,7 +1945,7 @@ void M_Drawer (void)
string[i] = '\0';
}
- foundnewline = 1;
+ foundnewline = true;
start += i + 1;
break;
}