aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2015-07-03 00:57:25 +0200
committerMartin Kiewitz2015-07-03 00:57:25 +0200
commita4d3ad396cddae75791f07ff5e87db788f617e3f (patch)
treec83dbb96d8e71157014d5f0b0e022e29a6b0a34c /engines
parentbfa7d895002198a364a599893953f911f2095ce6 (diff)
downloadscummvm-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.cpp13
-rw-r--r--engines/agos/drivers/accolade/mt32.cpp13
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;
}