aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorlukaslw2014-07-24 18:53:55 +0200
committerlukaslw2014-07-24 18:53:55 +0200
commit9c9da0d65a413ad1992bf066b9df922d4b93013f (patch)
tree69a266a521d347fb668f230a16918d62f0ed6fc1 /engines
parent8829b20ce97c44b719c0cd2063f24062449a2f67 (diff)
downloadscummvm-rg350-9c9da0d65a413ad1992bf066b9df922d4b93013f.tar.gz
scummvm-rg350-9c9da0d65a413ad1992bf066b9df922d4b93013f.tar.bz2
scummvm-rg350-9c9da0d65a413ad1992bf066b9df922d4b93013f.zip
PRINCE: doZoomIn(), doZoomOut() - memory leak fix
Diffstat (limited to 'engines')
-rw-r--r--engines/prince/object.cpp7
-rw-r--r--engines/prince/prince.cpp10
2 files changed, 12 insertions, 5 deletions
diff --git a/engines/prince/object.cpp b/engines/prince/object.cpp
index 1edabb63e0..e4dece4426 100644
--- a/engines/prince/object.cpp
+++ b/engines/prince/object.cpp
@@ -38,11 +38,16 @@ Object::Object() : _surface(nullptr), _x(0), _y(0), _z(0), _flags(0), _width(0),
}
Object::~Object() {
- if (_surface) {
+ if (_surface != nullptr) {
_surface->free();
delete _surface;
_surface = nullptr;
}
+ if (_zoomSurface) {
+ _zoomSurface->free();
+ delete _zoomSurface;
+ _zoomSurface = nullptr;
+ }
}
void Object::loadSurface(Common::SeekableReadStream &stream) {
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index d6981ee90d..31702484d8 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -1512,7 +1512,8 @@ void PrinceEngine::doZoomIn(int slot) {
byte *dst1 = (byte *)object->_zoomSurface->getBasePtr(0, 0);
int x = 0;
int w, rand;
- for (int y = 0; y < orgSurface->h; y++) {
+ int surfaceHeight = orgSurface->h;
+ for (int y = 0; y < surfaceHeight; y++) {
byte *src2 = src1;
byte *dst2 = dst1;
w = orgSurface->w - x;
@@ -1524,7 +1525,7 @@ void PrinceEngine::doZoomIn(int slot) {
*(dst2 + rand) = *(src2 + rand);
src2 += zoomInStep;
dst2 += zoomInStep;
- } else {
+ } else if (y + 1 != surfaceHeight) {
*(dst1 + orgSurface->pitch + rand - w) = *(src1 + orgSurface->pitch + rand - w);
}
w -= zoomInStep;
@@ -1545,7 +1546,8 @@ void PrinceEngine::doZoomOut(int slot) {
byte *dst1 = (byte *)object->_zoomSurface->getBasePtr(0, 0);
int x = 0;
int w, rand;
- for (int y = 0; y < orgSurface->h; y++) {
+ int surfaceHeight = orgSurface->h;
+ for (int y = 0; y < surfaceHeight; y++) {
byte *dst2 = dst1;
w = orgSurface->w - x;
dst2 += x;
@@ -1554,7 +1556,7 @@ void PrinceEngine::doZoomOut(int slot) {
if (rand < w) {
*(dst2 + rand) = 255;
dst2 += zoomInStep;
- } else {
+ } else if (y + 1 != surfaceHeight) {
*(dst1 + orgSurface->pitch + rand - w) = 255;
}
w -= zoomInStep;