diff options
author | Martin Kiewitz | 2015-07-03 00:57:25 +0200 |
---|---|---|
committer | Martin Kiewitz | 2015-07-03 00:57:25 +0200 |
commit | a4d3ad396cddae75791f07ff5e87db788f617e3f (patch) | |
tree | c83dbb96d8e71157014d5f0b0e022e29a6b0a34c /engines | |
parent | bfa7d895002198a364a599893953f911f2095ce6 (diff) | |
download | scummvm-rg350-a4d3ad396cddae75791f07ff5e87db788f617e3f.tar.gz scummvm-rg350-a4d3ad396cddae75791f07ff5e87db788f617e3f.tar.bz2 scummvm-rg350-a4d3ad396cddae75791f07ff5e87db788f617e3f.zip |
AGOS: Accolade music driver: fix memory leak
in factory
Diffstat (limited to 'engines')
-rw-r--r-- | engines/agos/drivers/accolade/adlib.cpp | 13 | ||||
-rw-r--r-- | engines/agos/drivers/accolade/mt32.cpp | 13 |
2 files changed, 14 insertions, 12 deletions
diff --git a/engines/agos/drivers/accolade/adlib.cpp b/engines/agos/drivers/accolade/adlib.cpp index ed05fe19ac..11edc7c5f7 100644 --- a/engines/agos/drivers/accolade/adlib.cpp +++ b/engines/agos/drivers/accolade/adlib.cpp @@ -872,13 +872,14 @@ MidiDriver *MidiDriver_Accolade_AdLib_create(Common::String driverFilename) { error("ACCOLADE-ADLIB: error during readDriver()"); MidiDriver_Accolade_AdLib *driver = new MidiDriver_Accolade_AdLib(g_system->getMixer()); - if (!driver) - return nullptr; - - if (!driver->setupInstruments(driverData, driverDataSize, isMusicDrvFile)) { - delete driver; - return nullptr; + if (driver) { + if (!driver->setupInstruments(driverData, driverDataSize, isMusicDrvFile)) { + delete driver; + driver = nullptr; + } } + + delete[] driverData; return driver; } diff --git a/engines/agos/drivers/accolade/mt32.cpp b/engines/agos/drivers/accolade/mt32.cpp index 2a023297ee..319e0ebf56 100644 --- a/engines/agos/drivers/accolade/mt32.cpp +++ b/engines/agos/drivers/accolade/mt32.cpp @@ -264,13 +264,14 @@ MidiDriver *MidiDriver_Accolade_MT32_create(Common::String driverFilename) { error("ACCOLADE-ADLIB: error during readDriver()"); MidiDriver_Accolade_MT32 *driver = new MidiDriver_Accolade_MT32(); - if (!driver) - return nullptr; - - if (!driver->setupInstruments(driverData, driverDataSize, isMusicDrvFile)) { - delete driver; - return nullptr; + if (driver) { + if (!driver->setupInstruments(driverData, driverDataSize, isMusicDrvFile)) { + delete driver; + driver = nullptr; + } } + + delete[] driverData; return driver; } |