From 61d438e1eb1c7ab4ddcfb2e47af088bd28d799ca Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 4 Sep 2010 03:02:13 +0000 Subject: [PATCH] - Don't call M_NotifyNewSave() before closing the new savegame. - Disallow negative read lengths in FileReader::Read(). SVN r2685 (trunk) --- src/files.cpp | 2 ++ src/g_game.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/files.cpp b/src/files.cpp index 5705b938a..332bddb1f 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -132,6 +132,8 @@ long FileReader::Seek (long offset, int origin) long FileReader::Read (void *buffer, long len) { + assert(len >= 0); + if (len <= 0) return 0; if (FilePos + len > StartPos + Length) { len = Length - FilePos + StartPos; diff --git a/src/g_game.cpp b/src/g_game.cpp index f85601c6e..39a424097 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -2060,11 +2060,11 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio M_AppendPNGChunk (stdfile, MAKE_ID('s','n','X','t'), &next, 1); } - M_NotifyNewSave (filename.GetChars(), description, okForQuicksave); - M_FinishPNG (stdfile); fclose (stdfile); + M_NotifyNewSave (filename.GetChars(), description, okForQuicksave); + // Check whether the file is ok. bool success = false; stdfile = fopen (filename.GetChars(), "rb");