diff options
author | Aaryaman Vasishta | 2016-12-30 22:50:41 +0900 |
---|---|---|
committer | Aaryaman Vasishta | 2016-12-31 00:55:33 +0900 |
commit | cc917882a69a1d670b5e23d23a496bc2ad9da62b (patch) | |
tree | c4ac0e896d1801391d98ea57ba9071d133702b59 | |
parent | e78abf4e061ca7c8a144c1123e54381580ae3f41 (diff) | |
download | scummvm-rg350-cc917882a69a1d670b5e23d23a496bc2ad9da62b.tar.gz scummvm-rg350-cc917882a69a1d670b5e23d23a496bc2ad9da62b.tar.bz2 scummvm-rg350-cc917882a69a1d670b5e23d23a496bc2ad9da62b.zip |
FULLPIPE: Fix leaks in surface and bitmap usage.
Fixes part of bug #9654.
-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) { |