From 6ccfac7e3349733b5ef0b5c3bd320a1313a575cc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 17 Apr 2013 17:08:58 +0200 Subject: WINTERMUTE: Avoid dereferncing null-pointer in TransparentSurface --- engines/wintermute/graphics/transparent_surface.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/wintermute') diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 11aeb26821..dcdcbf247e 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -218,7 +218,7 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p height = height * 2 / 3; #endif - Graphics::Surface *img; + Graphics::Surface *img = nullptr; Graphics::Surface *imgScaled = nullptr; byte *savedPixels = nullptr; if ((width != srcImage.w) || (height != srcImage.h)) { @@ -371,14 +371,15 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p } } + retSize.setWidth(img->w); + retSize.setHeight(img->h); + if (imgScaled) { imgScaled->pixels = savedPixels; imgScaled->free(); delete imgScaled; } - retSize.setWidth(img->w); - retSize.setHeight(img->h); return retSize; } -- cgit v1.2.3