From 9a2f3d3377b82b597f00d1d8fb8ee58d141cfb95 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Fri, 9 Dec 2011 21:12:14 +0000 Subject: More string safety stuff --- Stars45/CampaignSaveGame.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Stars45/CampaignSaveGame.cpp') diff --git a/Stars45/CampaignSaveGame.cpp b/Stars45/CampaignSaveGame.cpp index 6ad81a2..8320259 100644 --- a/Stars45/CampaignSaveGame.cpp +++ b/Stars45/CampaignSaveGame.cpp @@ -58,7 +58,7 @@ CampaignSaveGame::GetSaveDirectory(Player* player) { if (player) { char save_dir[32]; - sprintf(save_dir, "%s/%02d", SAVE_DIR, player->Identity()); + sprintf_s(save_dir, "%s/%02d", SAVE_DIR, player->Identity()); return save_dir; } @@ -563,7 +563,9 @@ CampaignSaveGame::Save(const char* name) Text s = GetSaveDirectory() + Text("/") + Text(name); - FILE* f = fopen(s, "w"); + FILE* f; + fopen_s(&f, s, "w"); + if (f) { char timestr[32]; FormatDayTime(timestr, campaign->GetTime()); @@ -704,7 +706,9 @@ Text CampaignSaveGame::GetResumeFile() { // check for auto save game: - FILE* f = ::fopen(GetSaveDirectory() + "/AutoSave", "r"); + FILE* f; + ::fopen_s(&f, GetSaveDirectory() + "/AutoSave", "r"); + if (f) { ::fclose(f); -- cgit v1.1