Skip to content

Commit

Permalink
Merge pull request #878 from jammm/master
Browse files Browse the repository at this point in the history
FULLPIPE: Fix leaks in surface and bitmap usage.
  • Loading branch information
sev- committed Dec 30, 2016
2 parents 09258a6 + cc91788 commit 5951649
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions engines/fullpipe/gfx.cpp
Expand Up @@ -479,7 +479,7 @@ void Picture::freePicture() {
if (_bitmap) {
if (testFlags() && !_field_54) {
freeData();
//free(_bitmap);
free(_bitmap);
_bitmap = 0;
}
}
Expand Down Expand Up @@ -772,6 +772,7 @@ Bitmap::Bitmap() {
_flags = 0;
_surface = 0;
_flipping = Graphics::FLIP_NONE;
_copied_surface = false;
}

Bitmap::Bitmap(Bitmap *src) {
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions engines/fullpipe/gfx.h
Expand Up @@ -45,6 +45,7 @@ struct Bitmap {
int _flags;
Graphics::TransparentSurface *_surface;
int _flipping;
bool _copied_surface;

Bitmap();
Bitmap(Bitmap *src);
Expand Down
2 changes: 2 additions & 0 deletions engines/fullpipe/statics.cpp
Expand Up @@ -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) {
Expand Down

0 comments on commit 5951649

Please sign in to comment.