diff options
author | Filippos Karapetis | 2015-12-18 14:19:58 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:34:10 +0100 |
commit | f1bb844e90cd9722170c1a02dd23a7a4cded1943 (patch) | |
tree | f4327c4e51e4548a0be1e9543494e41813f9711c /engines | |
parent | 5c480485d45f5bdcc783d7962af471638f6b91aa (diff) | |
download | scummvm-rg350-f1bb844e90cd9722170c1a02dd23a7a4cded1943.tar.gz scummvm-rg350-f1bb844e90cd9722170c1a02dd23a7a4cded1943.tar.bz2 scummvm-rg350-f1bb844e90cd9722170c1a02dd23a7a4cded1943.zip |
LAB: Fix a memory leak in the Image class
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lab/engine.cpp | 6 | ||||
-rw-r--r-- | engines/lab/image.cpp | 6 | ||||
-rw-r--r-- | engines/lab/image.h | 3 |
3 files changed, 9 insertions, 6 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp index a229b68dd4..5eed831d11 100644 --- a/engines/lab/engine.cpp +++ b/engines/lab/engine.cpp @@ -1229,8 +1229,7 @@ int LabEngine::followCrumbs() { void LabEngine::mayShowCrumbIndicator() { - static byte dropCrumbs[] = { 0x00 }; - static Image dropCrumbsImage(24, 24, dropCrumbs, this); + static Image dropCrumbsImage(24, 24, nullptr, this); if (getPlatform() != Common::kPlatformWindows) return; @@ -1242,8 +1241,7 @@ void LabEngine::mayShowCrumbIndicator() { } void LabEngine::mayShowCrumbIndicatorOff() { - static byte dropCrumbsOff[] = { 0x00 }; - static Image dropCrumbsOffImage(24, 24, dropCrumbsOff, this); + static Image dropCrumbsOffImage(24, 24, nullptr, this); if (getPlatform() != Common::kPlatformWindows) return; diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp index 6ace005f9f..2e0ecc196d 100644 --- a/engines/lab/image.cpp +++ b/engines/lab/image.cpp @@ -49,10 +49,14 @@ Image::Image(Common::File *s, LabEngine *vm) : _vm(vm) { if (size & 1) size++; - _imageData = new byte[size]; // FIXME: Memory leak! + _imageData = new byte[size]; s->read(_imageData, size); } +Image::~Image() { + delete _imageData; +} + /** * Blits a piece of one image to another. */ diff --git a/engines/lab/image.h b/engines/lab/image.h index 90ea1f3ada..e95125eaab 100644 --- a/engines/lab/image.h +++ b/engines/lab/image.h @@ -47,9 +47,10 @@ public: uint16 _height; byte *_imageData; - Image(LabEngine *vm) : _width(0), _height(0), _imageData(0), _vm(vm) {} + Image(LabEngine *vm) : _width(0), _height(0), _imageData(nullptr), _vm(vm) {} Image(int w, int h, byte *d, LabEngine *vm) : _width(w), _height(h), _imageData(d), _vm(vm) {} Image(Common::File *s, LabEngine *vm); + virtual ~Image(); void drawImage(uint16 x, uint16 y); void drawMaskImage(uint16 x, uint16 y); |