From 4fcb00a8356b8a617d17fa9dc8c128d2add72bd1 Mon Sep 17 00:00:00 2001 From: sluicebox <22204938+sluicebox@users.noreply.github.com> Date: Thu, 2 Nov 2023 09:26:16 -0700 Subject: [PATCH] NGI: Fix memory leaks when flipping bitmaps Coverity CID 1433114 Coverity CID 1433128 --- engines/ngi/gfx.cpp | 4 +++- engines/ngi/statics.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp index 5858761232e..680b50526db 100644 --- a/engines/ngi/gfx.cpp +++ b/engines/ngi/gfx.cpp @@ -577,7 +577,9 @@ void Picture::draw(int x, int y, int style, int angle) { case 1: { //flip const Dims dims = getDimensions(); - _bitmap->flipVertical()->drawShaded(1, x1, y1 + 30 + dims.y, *pal, _alpha); + Bitmap *flipped = _bitmap->flipVertical(); + flipped->drawShaded(1, x1, y1 + 30 + dims.y, *pal, _alpha); + delete flipped; break; } case 2: diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp index a27113da6ba..f5be08befac 100644 --- a/engines/ngi/statics.cpp +++ b/engines/ngi/statics.cpp @@ -496,7 +496,9 @@ void Movement::draw(bool flipFlag, int angle) { } if (flipFlag) { - bmp->flipVertical()->drawShaded(1, x, y + 30 + _currDynamicPhase->_rect.bottom, _currDynamicPhase->getPaletteData(), _currDynamicPhase->getAlpha()); + Bitmap *flipped = bmp->flipVertical(); + flipped->drawShaded(1, x, y + 30 + _currDynamicPhase->_rect.bottom, _currDynamicPhase->getPaletteData(), _currDynamicPhase->getAlpha()); + delete flipped; } else if (angle) { bmp->drawRotated(x, y, angle, _currDynamicPhase->getPaletteData(), _currDynamicPhase->getAlpha()); } else {