[Scummvm-git-logs] scummvm master -> 9075cbc1ba9d01833e9ec94d53eba5cdd81abed2

sev- sev at scummvm.org
Mon Dec 12 23:00:58 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9075cbc1ba FULLPIPE: Fix memory leak in bitmap code


Commit: 9075cbc1ba9d01833e9ec94d53eba5cdd81abed2
    https://github.com/scummvm/scummvm/commit/9075cbc1ba9d01833e9ec94d53eba5cdd81abed2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-12-12T23:00:41+01:00

Commit Message:
FULLPIPE: Fix memory leak in bitmap code

Changed paths:
    engines/fullpipe/gfx.cpp
    engines/fullpipe/gfx.h
    engines/fullpipe/statics.cpp


diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index 145f4e8..466f123 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 566586f..f8396c9 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 ab4e757..7f43fa0 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() {





More information about the Scummvm-git-logs mailing list