shithub: choc

Download patch

ref: 1e7908feb322f4ad8a88008964f1558861348ae6
parent: 81f8ac6c5718ac37dcc713a6e092493190c1998b
author: James Haley <[email protected]>
date: Sun Apr 1 23:21:45 EDT 2012

Fix to undefined sprintf behavior in the dialog engine (thanks to
MP2E!). Other changes are to comments only.

Subversion-branch: /branches/v2-branch
Subversion-revision: 2509

--- a/src/strife/p_dialog.c
+++ b/src/strife/p_dialog.c
@@ -1057,6 +1057,7 @@
     int height;
     int finaly;
     char choicetext[64];
+    char choicetext2[64];
 
     // Run down bonuscount faster than usual so that flashes from being given
     // items are less obvious.
@@ -1130,9 +1131,11 @@
             // alternate text for items that need money
             if(currentdialog->choices[i].needamounts[0] > 0)
             {
+                // haleyjd 20120401: necessary to avoid undefined behavior:
+                strcpy(choicetext2, choicetext);
                 DEH_snprintf(choicetext, sizeof(choicetext),
                              "%s for %d", 
-                             choicetext, 
+                             choicetext2, 
                              currentdialog->choices[i].needamounts[0]);
             }
 
--- a/src/strife/p_inter.c
+++ b/src/strife/p_inter.c
@@ -260,7 +260,6 @@
         // Set mo->health for consistency.
         // haleyjd 20110225: Seems Strife can call this on a NULL player->mo
         // when giving items to players that are not in the game...
-        // STRIFE-FIXME: needs major verification!
         mo = P_SubstNullMobj(player->mo);
         mo->health = player->health;
     }
@@ -287,7 +286,7 @@
         if(player->health >= healing)
             return false;
 
-        // Set health. Oddly, mo->health is NOT set here...
+        // Set health. BUG: Oddly, mo->health is NOT set here...
         player->health = healing;
     }