[Scummvm-git-logs] scummvm master -> 54ee96f8978bb1f5136d968e306c20f0881a9223

grisenti noreply at scummvm.org
Fri Dec 15 15:36:18 UTC 2023


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

Summary:
54ee96f897 HPL1: Fix potential null dereferences


Commit: 54ee96f8978bb1f5136d968e306c20f0881a9223
    https://github.com/scummvm/scummvm/commit/54ee96f8978bb1f5136d968e306c20f0881a9223
Author: grisenti (emanuele at grisenti.net)
Date: 2023-12-15T16:36:05+01:00

Commit Message:
HPL1: Fix potential null dereferences

Changed paths:
    engines/hpl1/engine/ai/StateMachine.cpp
    engines/hpl1/engine/impl/MeshLoaderCollada.cpp
    engines/hpl1/engine/scene/Scene.cpp
    engines/hpl1/penumbra-overture/GameEnemy.cpp
    engines/hpl1/penumbra-overture/PlayerState.h
    engines/hpl1/penumbra-overture/PreMenu.cpp


diff --git a/engines/hpl1/engine/ai/StateMachine.cpp b/engines/hpl1/engine/ai/StateMachine.cpp
index e5a3508f4ec..6aff6bf97de 100644
--- a/engines/hpl1/engine/ai/StateMachine.cpp
+++ b/engines/hpl1/engine/ai/StateMachine.cpp
@@ -118,8 +118,7 @@ void cStateMachine::ChangeState(int alId) {
 		return;
 	}
 
-	if (mpCurrentState)
-		mpCurrentState->OnLeaveState(pState->GetId());
+	mpCurrentState->OnLeaveState(pState->GetId());
 	pState->OnEnterState(mpCurrentState == NULL ? -1 : mpCurrentState->GetId());
 
 	mpCurrentState = pState;
diff --git a/engines/hpl1/engine/impl/MeshLoaderCollada.cpp b/engines/hpl1/engine/impl/MeshLoaderCollada.cpp
index 26746c2c4a0..ee9f0b2af08 100644
--- a/engines/hpl1/engine/impl/MeshLoaderCollada.cpp
+++ b/engines/hpl1/engine/impl/MeshLoaderCollada.cpp
@@ -1422,6 +1422,7 @@ cMeshEntity *cMeshLoaderCollada::CreateStaticMeshEntity(cColladaNode *apNode, cW
 			// Log("Created body %s!\n",pBody->GetName().c_str());
 		} else {
 			Log("Body creation failed!\n");
+			return nullptr;
 		}
 
 		// Check if it blocks light
diff --git a/engines/hpl1/engine/scene/Scene.cpp b/engines/hpl1/engine/scene/Scene.cpp
index 49c661674fe..845f05520c9 100644
--- a/engines/hpl1/engine/scene/Scene.cpp
+++ b/engines/hpl1/engine/scene/Scene.cpp
@@ -268,9 +268,8 @@ void cScene::Render(cUpdater *apUpdater, float afFrameTime) {
 
 			if (mpCurrentWorld2D) {
 				mpCurrentWorld2D->Render(pCamera2D);
+				mpGraphics->GetRenderer2D()->RenderObjects(pCamera2D, mpCurrentWorld2D->GetGridMapLights(), mpCurrentWorld2D);
 			}
-
-			mpGraphics->GetRenderer2D()->RenderObjects(pCamera2D, mpCurrentWorld2D->GetGridMapLights(), mpCurrentWorld2D);
 		} else {
 			cCamera3D *pCamera3D = static_cast<cCamera3D *>(mpActiveCamera);
 
diff --git a/engines/hpl1/penumbra-overture/GameEnemy.cpp b/engines/hpl1/penumbra-overture/GameEnemy.cpp
index 5a92d1fc710..f461b7aca8a 100644
--- a/engines/hpl1/penumbra-overture/GameEnemy.cpp
+++ b/engines/hpl1/penumbra-overture/GameEnemy.cpp
@@ -1378,7 +1378,7 @@ void iGameEnemy::UpdateAnimations(float afTimeStep) {
 
 		/////////////////////////////////
 		// Update animation speed
-		if (mbAnimationIsSpeedDependant) {
+		if (mbAnimationIsSpeedDependant && mpCurrentAnimation) {
 			if (ABS(fSpeed) > 0.05f)
 				mpCurrentAnimation->SetSpeed(ABS(fSpeed) * mfMoveAnimSpeedMul);
 			else
diff --git a/engines/hpl1/penumbra-overture/PlayerState.h b/engines/hpl1/penumbra-overture/PlayerState.h
index e0f52a29389..cc484e1bb8d 100644
--- a/engines/hpl1/penumbra-overture/PlayerState.h
+++ b/engines/hpl1/penumbra-overture/PlayerState.h
@@ -63,10 +63,9 @@ public:
 	void InitState(iPlayerState *apPrevState) {
 		if (apPrevState) {
 			apPrevState->LeaveState(this);
+			EnterState(apPrevState);
+			mPreviuosState = apPrevState->mType;
 		}
-
-		EnterState(apPrevState);
-		mPreviuosState = apPrevState->mType;
 	}
 
 	//-------------------------------------
diff --git a/engines/hpl1/penumbra-overture/PreMenu.cpp b/engines/hpl1/penumbra-overture/PreMenu.cpp
index c30f47df593..b9550e24aaa 100644
--- a/engines/hpl1/penumbra-overture/PreMenu.cpp
+++ b/engines/hpl1/penumbra-overture/PreMenu.cpp
@@ -96,6 +96,7 @@ void cPreMenu::LoadConfig() {
 	if (pMainElem == NULL) {
 		Error("Couldn't load Main element from XML document 'config/startup.cfg'\n");
 		hplDelete(pXmlDoc);
+		return;
 	}
 
 	mbShowText = cString::ToBool(pMainElem->Attribute("ShowText"), false);
@@ -106,6 +107,7 @@ void cPreMenu::LoadConfig() {
 	if (pLogosParentElem == NULL) {
 		Error("Couldn't load Logs element from XML document 'config/startup.cfg'\n");
 		hplDelete(pXmlDoc);
+		return;
 	}
 
 	////////////////////////////////////////////////




More information about the Scummvm-git-logs mailing list