From f24ccdecc04cf912c29093df1422ebde155f4aef Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 1 Nov 2014 18:01:28 +0000 Subject: [PATCH] menus.c: prevent using a null pointer as arg to "%s" format for sprintf(). DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4712 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/menus.c | 7 +++++-- polymer/eduke32/source/savegame.h | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index d1fb8f97c..26263ec9b 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -101,7 +101,6 @@ int32_t menutext_(int32_t x, int32_t y, int32_t s, int32_t p, char *t, int32_t b #pragma pack(push,1) static savehead_t savehead; -//static struct savehead_ savehead; #pragma pack(pop) static void M_DrawBackground(const vec2_t origin) @@ -1924,7 +1923,11 @@ static void M_PreMenuDraw(MenuID_t cm, MenuGroup_t *group, MenuEntry_t *entry, c mgametextcenter(origin.x, origin.y + (156<<16), tempbuf); } - Bsprintf(tempbuf,"%s / %s",MapInfo[(savehead.volnum*MAXLEVELS) + savehead.levnum].name, SkillNames[savehead.skill-1]); + { + const char *name = MapInfo[(savehead.volnum*MAXLEVELS) + savehead.levnum].name; + Bsprintf(tempbuf, "%s / %s", name ? name : "^10unnamed^0", SkillNames[savehead.skill-1]); + } + mgametextcenter(origin.x, origin.y + (168<<16), tempbuf); if (savehead.volnum == 0 && savehead.levnum == 7) mgametextcenter(origin.x, origin.y + (180<<16), savehead.boardfn); diff --git a/polymer/eduke32/source/savegame.h b/polymer/eduke32/source/savegame.h index 9c7c198e3..6a61a3a88 100644 --- a/polymer/eduke32/source/savegame.h +++ b/polymer/eduke32/source/savegame.h @@ -66,7 +66,6 @@ void sv_freemem(); int32_t G_SavePlayer(int32_t spot); int32_t G_LoadPlayer(int32_t spot); int32_t G_LoadSaveHeaderNew(int32_t spot, savehead_t *saveh); -//int32_t G_LoadSaveHeader(char spot,struct savehead_ *saveh); void ReadSaveGameHeaders(void); void G_SavePlayerMaybeMulti(int32_t slot); void G_LoadPlayerMaybeMulti(int32_t slot);