summaryrefslogtreecommitdiff
path: root/src/p_saveg.c
diff options
context:
space:
mode:
authorSimon Howard2008-04-19 13:43:17 +0000
committerSimon Howard2008-04-19 13:43:17 +0000
commit974228a52920aeb89b3f1f19184aa9ffcc037ef5 (patch)
tree5d86d98fc7f3d41f48216583f9da9a74aeb93650 /src/p_saveg.c
parent33616f49d8a394b4db5fc237d59a898973270c53 (diff)
downloadchocolate-doom-974228a52920aeb89b3f1f19184aa9ffcc037ef5.tar.gz
chocolate-doom-974228a52920aeb89b3f1f19184aa9ffcc037ef5.tar.bz2
chocolate-doom-974228a52920aeb89b3f1f19184aa9ffcc037ef5.zip
Don't successfully save a savegame if a buffer overrun occurs, and don't
overwrite the existing savegame. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1119
Diffstat (limited to 'src/p_saveg.c')
-rw-r--r--src/p_saveg.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/p_saveg.c b/src/p_saveg.c
index afd3852d..40b5f988 100644
--- a/src/p_saveg.c
+++ b/src/p_saveg.c
@@ -44,11 +44,36 @@
FILE *save_stream;
int savegamelength;
+// Get the filename of a temporary file to write the savegame to. After
+// the file has been successfully saved, it will be renamed to the
+// real file.
+
+char *P_TempSaveGameFile(void)
+{
+ static char *filename = NULL;
+
+ if (filename == NULL)
+ {
+ filename = malloc(strlen(savegamedir) + 32);
+ }
+
+ sprintf(filename, "%stemp.dsg", savegamedir);
+
+ return filename;
+}
+
+// Get the filename of the save game file to use for the specified slot.
+
char *P_SaveGameFile(int slot)
{
- static char filename[256];
+ static char *filename = NULL;
char basename[32];
+ if (filename == NULL)
+ {
+ filename = malloc(strlen(savegamedir) + 32);
+ }
+
sprintf(basename, DEH_String(SAVEGAMENAME "%d.dsg"), slot);
sprintf(filename, "%s%s", savegamedir, basename);