aboutsummaryrefslogtreecommitdiff
path: root/engines/tony
diff options
context:
space:
mode:
authorTorbjörn Andersson2013-06-02 22:13:59 +0200
committerTorbjörn Andersson2013-06-02 22:13:59 +0200
commit1cc0e9cb8813a39c9f9d95287b811dbb534e3868 (patch)
treea7b9e6f5fcf255b4dfc5547c6fab5460f4f73b84 /engines/tony
parent9d28a6f531ad3727675604e24cdeff5ce03decc3 (diff)
downloadscummvm-rg350-1cc0e9cb8813a39c9f9d95287b811dbb534e3868.tar.gz
scummvm-rg350-1cc0e9cb8813a39c9f9d95287b811dbb534e3868.tar.bz2
scummvm-rg350-1cc0e9cb8813a39c9f9d95287b811dbb534e3868.zip
TONY: Fix memory leak on save game failure (CID 1003579)
Though shouldn't it also alert the user to the failure?
Diffstat (limited to 'engines/tony')
-rw-r--r--engines/tony/gfxengine.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp
index cb27e20ab1..7bb25f59b9 100644
--- a/engines/tony/gfxengine.cpp
+++ b/engines/tony/gfxengine.cpp
@@ -530,7 +530,10 @@ void RMGfxEngine::disableMouse() {
#define TONY_SAVEGAME_VERSION 8
void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Common::String &name) {
- Common::OutSaveFile *f;
+ Common::OutSaveFile *f = g_system->getSavefileManager()->openForSaving(fn);
+ if (f == NULL)
+ return;
+
byte *state;
char buf[4];
RMPoint tp = _tony.position();
@@ -549,10 +552,6 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm
buf[2] = 'S';
buf[3] = TONY_SAVEGAME_VERSION;
- f = g_system->getSavefileManager()->openForSaving(fn);
- if (f == NULL)
- return;
-
f->write(buf, 4);
f->writeUint32LE(thumbsize);
f->write(curThumb, thumbsize);