From edb2edf3f4d1c062d9dc391a83f10cf71f7e4f85 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 3 Apr 2020 22:34:59 +0200 Subject: [PATCH] DIRECTOR: Fix memory leaks --- engines/director/lingo/lingo-funcs.cpp | 2 ++ engines/director/sound.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp index 7a75923e2fb..be1e5909dad 100644 --- a/engines/director/lingo/lingo-funcs.cpp +++ b/engines/director/lingo/lingo-funcs.cpp @@ -399,6 +399,8 @@ void Lingo::func_cursor(int c, int m) { warning("STUB: func_cursor(): Hotspot is the registration point of the cast member"); _vm->getMacWindowManager()->pushCustomCursor(assembly, 16, 16, 1, 1, 3); + free(assembly); + return; } diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp index 009b69b15a2..79fb1ded346 100644 --- a/engines/director/sound.cpp +++ b/engines/director/sound.cpp @@ -88,13 +88,14 @@ void DirectorSound::playFile(Common::String filename, uint8 soundChannel) { } void DirectorSound::playWAV(Common::String filename, uint8 soundChannel) { - Common::File *file = new Common::File(); - if (soundChannel == 0 || soundChannel > _channels.size()) { warning("Invalid sound channel %d", soundChannel); + return; } + Common::File *file = new Common::File(); + if (!file->open(filename)) { warning("Failed to open %s", filename.c_str()); @@ -110,13 +111,13 @@ void DirectorSound::playWAV(Common::String filename, uint8 soundChannel) { } void DirectorSound::playAIFF(Common::String filename, uint8 soundChannel) { - Common::File *file = new Common::File(); - if (soundChannel == 0 || soundChannel > _channels.size()) { warning("Invalid sound channel %d", soundChannel); return; } + Common::File *file = new Common::File(); + if (!file->open(filename)) { warning("Failed to open %s", filename.c_str()); delete file;