diff options
author | Eugene Sandulenko | 2016-12-30 18:32:43 +0100 |
---|---|---|
committer | GitHub | 2016-12-30 18:32:43 +0100 |
commit | 5951649b4dd6b4c720f80d5e82cfc734db504c44 (patch) | |
tree | 2cff08d20ab3346507478cb1596c0af75d00cffb /engines | |
parent | 09258a6d60b0e719d46ba72a6f4d4589002afcfa (diff) | |
parent | cc917882a69a1d670b5e23d23a496bc2ad9da62b (diff) | |
download | scummvm-rg350-5951649b4dd6b4c720f80d5e82cfc734db504c44.tar.gz scummvm-rg350-5951649b4dd6b4c720f80d5e82cfc734db504c44.tar.bz2 scummvm-rg350-5951649b4dd6b4c720f80d5e82cfc734db504c44.zip |
Merge pull request #878 from jammm/master
FULLPIPE: Fix leaks in surface and bitmap usage.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/gfx.cpp | 10 | ||||
-rw-r--r-- | engines/fullpipe/gfx.h | 1 | ||||
-rw-r--r-- | engines/fullpipe/statics.cpp | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index ea07621cd4..619f41d6da 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -479,7 +479,7 @@ void Picture::freePicture() { if (_bitmap) { if (testFlags() && !_field_54) { freeData(); - //free(_bitmap); + free(_bitmap); _bitmap = 0; } } @@ -772,6 +772,7 @@ Bitmap::Bitmap() { _flags = 0; _surface = 0; _flipping = Graphics::FLIP_NONE; + _copied_surface = false; } Bitmap::Bitmap(Bitmap *src) { @@ -784,15 +785,16 @@ Bitmap::Bitmap(Bitmap *src) { _height = src->_height; _pixels = src->_pixels; _surface = new Graphics::TransparentSurface(*src->_surface); + _copied_surface = true; _flipping = src->_flipping; } Bitmap::~Bitmap() { - if (_pixels) - free(_pixels); - _surface->free(); + if (!_copied_surface) + _surface->free(); delete _surface; + _surface = 0; _pixels = 0; } diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h index 1b4b4d3cef..43c23b49bc 100644 --- a/engines/fullpipe/gfx.h +++ b/engines/fullpipe/gfx.h @@ -45,6 +45,7 @@ struct Bitmap { int _flags; Graphics::TransparentSurface *_surface; int _flipping; + bool _copied_surface; Bitmap(); Bitmap(Bitmap *src); diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index ece4f43e9f..bc66ebf40b 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -552,6 +552,8 @@ void Movement::draw(bool flipFlag, int angle) { } else { bmp->putDib(x, y, (int32 *)_currDynamicPhase->_paletteData, _currDynamicPhase->_alpha); } + //Prevent memory leak after new was used to create bmp in reverseImage() + delete bmp; if (_currDynamicPhase->_rect->top) { if (!_currDynamicPhase->_convertedBitmap) { |