aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorBorja Lorente2016-08-26 12:26:29 +0200
committerBorja Lorente2016-08-26 12:27:16 +0200
commitec6bb1431eb3e54f4a1dddd051cb9b8dfa14f43d (patch)
tree9f4faf82ac4ad7ccf8a16335c82077d5909b1642 /graphics
parent5bba0897246de34318ac6049402b9d5f58722aa4 (diff)
downloadscummvm-rg350-ec6bb1431eb3e54f4a1dddd051cb9b8dfa14f43d.tar.gz
scummvm-rg350-ec6bb1431eb3e54f4a1dddd051cb9b8dfa14f43d.tar.bz2
scummvm-rg350-ec6bb1431eb3e54f4a1dddd051cb9b8dfa14f43d.zip
GRAPHICS: Fix leak in ninepatch destructor
Diffstat (limited to 'graphics')
-rw-r--r--graphics/macgui/macwindow.cpp10
-rw-r--r--graphics/nine_patch.cpp4
2 files changed, 9 insertions, 5 deletions
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index abb91f180d..975d52639e 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -317,14 +317,14 @@ void MacWindow::setScroll(float scrollPos, float scrollSize) {
void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo, int ro, int to, int bo) {
Image::BitmapDecoder bmpDecoder;
- Graphics::Surface source;
+ Graphics::Surface *source;
Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
bmpDecoder.loadStream(file);
- source = *(bmpDecoder.getSurface());
+ source = bmpDecoder.getSurface()->convertTo(surface->getSupportedPixelFormat(), bmpDecoder.getPalette());
- source.convertToInPlace(surface->getSupportedPixelFormat(), bmpDecoder.getPalette());
- surface->copyFrom(source);
+ surface->create(source->w, source->h, surface->getSupportedPixelFormat());
+ surface->copyFrom(*source);
surface->applyColorKey(255, 0, 255, false);
if (active)
@@ -336,6 +336,8 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo
_macBorder.setOffsets(lo, ro, to, bo);
updateInnerDims();
+ source->free();
+ delete source;
}
void MacWindow::setCloseable(bool closeable) {
diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index 9cee90864a..56e1202be3 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -260,8 +260,10 @@ void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, in
}
NinePatchBitmap::~NinePatchBitmap() {
- if (_destroy_bmp)
+ if (_destroy_bmp) {
+ _bmp->free();
delete _bmp;
+ }
}
void NinePatchBitmap::drawRegions(Graphics::Surface &target, int dx, int dy, int dw, int dh) {