aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJoseph-Eugene Winzer2018-01-07 23:09:01 +0100
committerThierry Crozat2018-01-23 02:15:46 +0000
commite40a0179628f312ebd8e8c0ae581dbd69fc2637a (patch)
tree4d7eaa0f5148cb5ad9fc567ad13ae7deadd26e64 /engines
parentc0f47712c2ac160a571959a86fd4b711f058ed64 (diff)
downloadscummvm-rg350-e40a0179628f312ebd8e8c0ae581dbd69fc2637a.tar.gz
scummvm-rg350-e40a0179628f312ebd8e8c0ae581dbd69fc2637a.tar.bz2
scummvm-rg350-e40a0179628f312ebd8e8c0ae581dbd69fc2637a.zip
SUPERNOVA: Fixes segfault if dat file not found
Diffstat (limited to 'engines')
-rw-r--r--engines/supernova/supernova.cpp5
-rw-r--r--engines/supernova/supernova.h19
2 files changed, 17 insertions, 7 deletions
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp
index 8f4394c1c8..1f0eb9b917 100644
--- a/engines/supernova/supernova.cpp
+++ b/engines/supernova/supernova.cpp
@@ -121,6 +121,8 @@ SupernovaEngine::SupernovaEngine(OSystem *syst)
DebugMan.addDebugChannel(kDebugGeneral, "general", "Supernova general debug channel");
_rnd = new Common::RandomSource("supernova");
+ _soundMusic[0] = NULL;
+ _soundMusic[1] = NULL;
}
SupernovaEngine::~SupernovaEngine() {
@@ -130,9 +132,6 @@ SupernovaEngine::~SupernovaEngine() {
delete _rnd;
delete _console;
delete _gm;
- for (int i = 0; i < kAudioNumSamples; ++i) {
- delete[] _soundSamples[i]._buffer;
- }
delete _soundMusic[0];
delete _soundMusic[1];
}
diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h
index 7a68b8ebcb..8b1fe40dad 100644
--- a/engines/supernova/supernova.h
+++ b/engines/supernova/supernova.h
@@ -76,6 +76,20 @@ private:
ScreenBuffer *_last;
};
+struct SoundSample {
+ SoundSample()
+ : _buffer(NULL)
+ , _length(0)
+ {}
+
+ ~SoundSample() {
+ delete _buffer;
+ }
+
+ byte *_buffer;
+ int _length;
+};
+
class SupernovaEngine : public Engine {
public:
explicit SupernovaEngine(OSystem *syst);
@@ -91,10 +105,7 @@ public:
byte _mouseNormal[256];
byte _mouseWait[256];
MSNImageDecoder *_currentImage;
- struct SoundSample {
- byte *_buffer;
- int _length;
- } _soundSamples[kAudioNumSamples];
+ SoundSample _soundSamples[kAudioNumSamples];
Common::MemoryReadStream *_soundMusic[2];
Common::Event _event;
int _screenWidth;