From 1cc0e9cb8813a39c9f9d95287b811dbb534e3868 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 2 Jun 2013 22:13:59 +0200 Subject: TONY: Fix memory leak on save game failure (CID 1003579) Though shouldn't it also alert the user to the failure? --- engines/tony/gfxengine.cpp | 9 ++++----- 1 file 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); -- cgit v1.2.3