[Scummvm-git-logs] scummvm master -> 8b6b4f7a48f162b194fa48c92d84ef4ee96c0e65

digitall noreply at scummvm.org
Wed May 28 00:41:45 UTC 2025


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
8b6b4f7a48 ALG: Fix Memory Leak in Graphics Surface Allocation


Commit: 8b6b4f7a48f162b194fa48c92d84ef4ee96c0e65
    https://github.com/scummvm/scummvm/commit/8b6b4f7a48f162b194fa48c92d84ef4ee96c0e65
Author: D G Turner (digitall at scummvm.org)
Date: 2025-05-28T01:38:59+01:00

Commit Message:
ALG: Fix Memory Leak in Graphics Surface Allocation

Indicated by running under Valgrind using leakcheck. Have tested and
this still runs Johnny Rock fine with this fix.

Have added note for other major leak, though some issues with surface
allocation in script calls remain.

Changed paths:
    engines/alg/graphics.cpp
    engines/alg/logic/game_johnnyrock.cpp


diff --git a/engines/alg/graphics.cpp b/engines/alg/graphics.cpp
index 5f4f8ca6f7f..8364de97ac7 100644
--- a/engines/alg/graphics.cpp
+++ b/engines/alg/graphics.cpp
@@ -143,6 +143,7 @@ Common::Array<Graphics::Surface *> *AlgGraphics::loadScreenCoordAniImage(const C
 		aniImage->copyRectToSurface(*renderTarget, 0, 0, subSectionRect);
 		images->push_back(aniImage);
 		renderTarget->free();
+		delete[] renderTarget;
 	}
 	aniFile.close();
 	return images;
diff --git a/engines/alg/logic/game_johnnyrock.cpp b/engines/alg/logic/game_johnnyrock.cpp
index 6788dac1caf..7f909e749fa 100644
--- a/engines/alg/logic/game_johnnyrock.cpp
+++ b/engines/alg/logic/game_johnnyrock.cpp
@@ -103,6 +103,7 @@ void GameJohnnyRock::init() {
 	moveMouse();
 }
 
+// FIXME: Need to unregisterScriptFunctions() in destructor to delete all allocated JRScriptFunctionRect and prevent reallocation to fix memory leakage here...
 void GameJohnnyRock::registerScriptFunctions() {
 #define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new JRScriptFunctionRect(this, &GameJohnnyRock::func);
 	RECT_HIT_FUNCTION("DEFAULT", rectNewScene);




More information about the Scummvm-git-logs mailing list