diff options
author | Eugene Sandulenko | 2016-12-12 23:00:41 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-12-12 23:00:41 +0100 |
commit | 9075cbc1ba9d01833e9ec94d53eba5cdd81abed2 (patch) | |
tree | 12512a3ab1dbce95c8840b55d5613f1c1e454b75 /engines | |
parent | 483fff04f67cd48a74ca3f90c87649d4f38649aa (diff) | |
download | scummvm-rg350-9075cbc1ba9d01833e9ec94d53eba5cdd81abed2.tar.gz scummvm-rg350-9075cbc1ba9d01833e9ec94d53eba5cdd81abed2.tar.bz2 scummvm-rg350-9075cbc1ba9d01833e9ec94d53eba5cdd81abed2.zip |
FULLPIPE: Fix memory leak in bitmap code
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/gfx.cpp | 13 | ||||
-rw-r--r-- | engines/fullpipe/gfx.h | 1 | ||||
-rw-r--r-- | engines/fullpipe/statics.cpp | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index 145f4e87b1..466f123ef8 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -779,6 +779,8 @@ Bitmap::Bitmap() { _flags = 0; _surface = 0; _flipping = Graphics::FLIP_NONE; + + _skipDelete = false; } Bitmap::Bitmap(Bitmap *src) { @@ -792,14 +794,21 @@ Bitmap::Bitmap(Bitmap *src) { _pixels = src->_pixels; _surface = new Graphics::TransparentSurface(*src->_surface); _flipping = src->_flipping; + + _skipDelete = true; } Bitmap::~Bitmap() { if (_pixels) free(_pixels); - _surface->free(); - delete _surface; + if (!_skipDelete) { + if (_surface) + _surface->free(); + delete _surface; + } + + _surface = 0; _pixels = 0; } diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h index 566586fb48..f8396c98cf 100644 --- a/engines/fullpipe/gfx.h +++ b/engines/fullpipe/gfx.h @@ -40,6 +40,7 @@ struct Bitmap { int _flags; Graphics::TransparentSurface *_surface; int _flipping; + bool _skipDelete; Bitmap(); Bitmap(Bitmap *src); diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index ab4e757c84..7f43fa0b1d 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -572,6 +572,8 @@ void Movement::draw(bool flipFlag, int angle) { } } } + + delete bmp; } void StaticANIObject::loadMovementsPixelData() { |