From 30f199a5a449d612e026b3d3a0ccace3a870c40e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 8 Sep 2010 11:45:17 +0000 Subject: SWORD25: Fix memory leak in transparency commit At the point where the alpha value was checked, a scaled image surface may have already been created, which needs to be freed. svn-id: r53337 --- engines/sword25/gfx/opengl/glimage.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/engines/sword25/gfx/opengl/glimage.cpp b/engines/sword25/gfx/opengl/glimage.cpp index 31a52fbed7..08f66e340d 100644 --- a/engines/sword25/gfx/opengl/glimage.cpp +++ b/engines/sword25/gfx/opengl/glimage.cpp @@ -204,7 +204,7 @@ bool GLImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRect, ui Graphics::Surface *img; Graphics::Surface *imgScaled = NULL; - byte *savedPixels; + byte *savedPixels = NULL; if ((width != srcImage.w) || (height != srcImage.h)) { // Scale the image img = imgScaled = scale(srcImage, width, height); @@ -218,10 +218,6 @@ bool GLImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRect, ui int cg = (color >> 8) & 0xff; int cb = (color >> 0) & 0xff; - // Check if we need to draw anything at all - if (ca == 0) - return true; - if (ca != 255) { cr = cr * ca >> 8; cg = cg * ca >> 8; @@ -244,7 +240,7 @@ bool GLImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRect, ui img->w = CLIP((int)img->w, 0, (int)MAX((int)_backSurface->w - posX, 0)); img->h = CLIP((int)img->h, 0, (int)MAX((int)_backSurface->h - posY, 0)); - if (img->w > 0 && img->h > 0) { + if ((ca != 0) && (img->w > 0) && (img->h > 0)) { int xp = 0, yp = 0; int inStep = 4; -- cgit v1.2.3