Browse Source

client/NetpacksClient.cpp: Called C++ object pointer is null

Null pointers should not be dereferenced
Alexander Wilms 2 năm trước cách đây
mục cha
commit
d2c03773cd
1 tập tin đã thay đổi với 16 bổ sung8 xóa
  1. 16 8
      client/NetPacksClient.cpp

+ 16 - 8
client/NetPacksClient.cpp

@@ -367,19 +367,27 @@ void ApplyClientNetPackVisitor::visitGiveBonus(GiveBonus & pack)
 void ApplyFirstClientNetPackVisitor::visitChangeObjPos(ChangeObjPos & pack)
 {
 	CGObjectInstance *obj = gs.getObjInstance(pack.objid);
-	if(CGI->mh)
-		CGI->mh->onObjectFadeOut(obj, pack.initiator);
-
-	CGI->mh->waitForOngoingAnimations();
+	if(CGI)
+	{
+		if(CGI->mh)
+		{
+			CGI->mh->onObjectFadeOut(obj, pack.initiator);
+			CGI->mh->waitForOngoingAnimations();
+		}
+	}
 }
 
 void ApplyClientNetPackVisitor::visitChangeObjPos(ChangeObjPos & pack)
 {
 	CGObjectInstance *obj = gs.getObjInstance(pack.objid);
-	if(CGI->mh)
-		CGI->mh->onObjectFadeIn(obj, pack.initiator);
-
-	CGI->mh->waitForOngoingAnimations();
+	if(CGI)
+	{
+		if(CGI->mh)
+		{
+			CGI->mh->onObjectFadeIn(obj, pack.initiator);
+			CGI->mh->waitForOngoingAnimations();
+		}
+	}
 	cl.invalidatePaths();
 }