HPL1: Fix potential null dereferences

This commit is contained in:
grisenti 2023-12-15 16:36:05 +01:00
parent 4dfeb27036
commit 54ee96f897
6 changed files with 8 additions and 8 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -63,10 +63,9 @@ public:
void InitState(iPlayerState *apPrevState) {
if (apPrevState) {
apPrevState->LeaveState(this);
EnterState(apPrevState);
mPreviuosState = apPrevState->mType;
}
EnterState(apPrevState);
mPreviuosState = apPrevState->mType;
}
//-------------------------------------

View File

@ -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;
}
////////////////////////////////////////////////