shithub: choc

Download patch

ref: 5705be4c622af4a4027a711c5dbbb42d9ce0ea8a
parent: c06b2c5f8e22d7cf54a502df5042de87d6d2218e
author: Simon Howard <[email protected]>
date: Sat Nov 3 08:37:00 EDT 2018

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.

--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -691,7 +691,7 @@
 //
 //      M_QuickSave
 //
-char    tempstring[80];
+static char tempstring[90];
 
 void M_QuickSaveResponse(int key)
 {
@@ -721,8 +721,9 @@
 	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 @@
 	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 @@
 	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 @@
                         string[i] = '\0';
                     }
 
-                    foundnewline = 1;
+                    foundnewline = true;
                     start += i + 1;
                     break;
                 }