[Scummvm-git-logs] scummvm master -> fb15fce9d68c52a500a0832d2ee4419a83ecdc6d

a-yyg 76591232+a-yyg at users.noreply.github.com
Sun Aug 15 09:29:57 UTC 2021


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:
fb15fce9d6 SAGA2: Fix wild pointer access in iterators


Commit: fb15fce9d68c52a500a0832d2ee4419a83ecdc6d
    https://github.com/scummvm/scummvm/commit/fb15fce9d68c52a500a0832d2ee4419a83ecdc6d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-08-15T18:29:20+09:00

Commit Message:
SAGA2: Fix wild pointer access in iterators

Changed paths:
    engines/saga2/actor.cpp
    engines/saga2/contain.cpp
    engines/saga2/dispnode.cpp
    engines/saga2/enchant.cpp
    engines/saga2/intrface.cpp
    engines/saga2/motion.cpp
    engines/saga2/objects.cpp
    engines/saga2/objproto.cpp
    engines/saga2/player.cpp
    engines/saga2/sagafunc.cpp
    engines/saga2/sensor.cpp
    engines/saga2/spelcast.cpp
    engines/saga2/target.cpp
    engines/saga2/tile.cpp
    engines/saga2/tilemode.cpp


diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index b29c12615c..6ff1b24625 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -3434,8 +3434,8 @@ void resumeActorStates(void) {
 //-------------------------------------------------------------------
 
 void setCombatBehavior(bool enabled) {
-	PlayerActor                     *player;
-	LivingPlayerActorIterator       iter;
+	PlayerActor *player = nullptr;
+	LivingPlayerActorIterator iter;
 
 	combatBehaviorEnabled = enabled;
 
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 50f228a151..a75fb94e17 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -307,8 +307,8 @@ bool ContainerView::isVisible(GameObject *item) {
 
 //  total the mass, bulk, and number of all objects in container.
 void ContainerView::totalObjects(void) {
-	ObjectID        objID;
-	GameObject      *item;
+	ObjectID objID;
+	GameObject *item = nullptr;
 
 	totalMass   = 0;
 	totalBulk   = 0;
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 0b5f84c2df..4749bb5737 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -227,10 +227,10 @@ void DisplayNodeList::buildObjects(bool fromScratch) {
 	if (currentWorld == NULL) return;
 
 	DispRegionObjectIterator    iter(currentWorld, viewCenter, loadDist);
-	GameObject                  *obj;
-	ObjectID                    id;
-	int16                       dist;
-	Actor                       *centerActor = getCenterActor();
+	GameObject *obj = nullptr;
+	ObjectID id;
+	int16 dist = 0;
+	Actor *centerActor = getCenterActor();
 
 	if (fromScratch)
 		//  Reset the list...
diff --git a/engines/saga2/enchant.cpp b/engines/saga2/enchant.cpp
index 1bcf62539d..73b0afa872 100644
--- a/engines/saga2/enchant.cpp
+++ b/engines/saga2/enchant.cpp
@@ -188,7 +188,7 @@ void addEnchantment(Actor *a, uint16 enchantmentID) {
 //	Function to eval the enchantments on an actor
 
 void evalActorEnchantments(Actor *a) {
-	GameObject          *obj;
+	GameObject          *obj = nullptr;
 	ObjectID            id;
 	PlayerActorID       playerID;
 	EnchantmentIterator iter(a);
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 524c811f78..19a3c886d5 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -2719,7 +2719,7 @@ void gEnchantmentDisplay::setValue(PlayerActorID pID) {
 	EnchantmentIterator iter(a);
 	ContainerIterator   cIter(a);
 
-	GameObject          *obj;
+	GameObject *obj = nullptr;
 
 	memset(newIconFlags, 0, sizeof newIconFlags);
 
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 7254415a18..e60a903372 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -2857,7 +2857,7 @@ void MotionTask::upLadderAction(void) {
 		TileRegion          actorTileReg;
 		TileInfo            *ti;
 		TilePoint           tileLoc;
-		StandingTileInfo    sti;
+		StandingTileInfo    sti = {nullptr, nullptr, {0, 0, 0}, 0};
 
 		loc.z += 6;
 
@@ -2983,7 +2983,7 @@ void MotionTask::downLadderAction(void) {
 		TileRegion          actorTileReg;
 		TileInfo            *ti;
 		TilePoint           tileLoc;
-		StandingTileInfo    sti;
+		StandingTileInfo    sti = {nullptr, nullptr, {0, 0, 0}, 0};
 
 		loc.z -= 6;
 
@@ -4696,7 +4696,7 @@ bool checkLadder(Actor *a, const TilePoint &loc) {
 	int16               mapNum = a->getMapNum();
 	TileInfo            *ti;
 	TilePoint           tileLoc;
-	StandingTileInfo    sti;
+	StandingTileInfo    sti = {nullptr, nullptr, {0, 0, 0}, 0};
 
 	actorTileReg.min.u = (loc.u - crossSection) >> kTileUVShift;
 	actorTileReg.min.v = (loc.v - crossSection) >> kTileUVShift;
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index bb949c917f..9247d623f7 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -786,7 +786,7 @@ int32 GameObject::getSprOffset(int16 num) {
 
 //  Remove an object from a stack of objects
 bool GameObject::unstack(void) {
-	GameObject  *item,
+	GameObject  *item = nullptr,
 	            *base = nullptr,
 	             *zero = nullptr;
 	int16       count = 0;
@@ -1467,7 +1467,7 @@ void GameObject::deactivate(void) {
 //  Determine if an object is contained in this object
 bool GameObject::isContaining(GameObject *item) {
 	ContainerIterator   iter(this);
-	GameObject          *containedObj;
+	GameObject          *containedObj = nullptr;
 
 	while (iter.next(&containedObj) != Nothing) {
 		if (containedObj == item) return true;
@@ -1563,7 +1563,7 @@ const char *GameObject::nameText(uint16 index) {
 
 TilePoint GameObject::getFirstEmptySlot(GameObject *obj) {
 	ObjectID        objID;
-	GameObject      *item;
+	GameObject      *item = nullptr;
 	TilePoint       newLoc, temp;
 	uint16          numRows = prototype->getMaxRows(),
 	                numCols = prototype->getMaxCols();
@@ -1654,7 +1654,7 @@ bool GameObject::getAvailableSlot(
 		TilePoint       firstEmptySlot;
 
 		if (canMerge) {
-			GameObject          *inventoryObj;
+			GameObject          *inventoryObj = nullptr;
 			ContainerIterator   iter(this);
 
 			//  Iterate through the objects in this container
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index f05082122c..7f92bb3876 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -1885,8 +1885,8 @@ GameObject *BowProto::getProjectile(ObjectID weapon, ObjectID enactor) {
 	assert(isObject(weapon));
 	assert(isActor(enactor));
 
-	GameObject          *obj,
-	                    *arrow = NULL;
+	GameObject          *obj = nullptr,
+	                    *arrow = nullptr;
 	Actor               *a = (Actor *)GameObject::objectAddress(enactor);
 	TilePoint           bestSlot(maxint16, maxint16, 0);
 	ContainerIterator   iter(a);
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index df35d9eda3..c9efe4dbba 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -657,7 +657,7 @@ void autoAdjustAggression(void) {
 			Actor           *actor = g_vm->_playerList[i]->getActor();
 
 			if (actor->getStats()->vitality >= kMinAutoAggressionVitality) {
-				GameObject      *obj;
+				GameObject      *obj = nullptr;
 				ActiveRegion    *activeReg = getActiveRegion(i);
 				TileRegion      region = activeReg->getRegion();
 				GameWorld       *world = activeReg->getWorld();
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index fb61804d77..4265d0081d 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -1022,7 +1022,7 @@ int16 deepCopy(GameObject *src, ObjectID parentID, TilePoint tp) {
 	OBJLOG(DeepCopy);
 	Location    l;
 	int16       newID, childID;
-	GameObject  *childObj;
+	GameObject  *childObj = nullptr;
 
 	l.u = tp.u;
 	l.v = tp.v;
@@ -2145,7 +2145,7 @@ int16 scriptActorCountPayment(int16 *args) {
 
 	ProtoObj    *currencyProto = g_vm->_objectProtos[args[0]];
 	int32       paymentFound = 0;
-	GameObject  *obj;
+	GameObject  *obj = nullptr;
 	ObjectID    id;
 	bool        mergeable =
 	    currencyProto->flags & ResourceObjectPrototype::objPropMergeable;
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index b05bd8a2d6..7a2a996aef 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -482,7 +482,7 @@ bool ObjectSensor::check(SenseInfo &info, uint32 senseFlags) {
 	    getObject()->world(),
 	    getObject()->getLocation(),
 	    getRange() != 0 ? getRange() : kTileUVSize * kPlatformWidth * 8);
-	GameObject              *objToTest;
+	GameObject              *objToTest = nullptr;
 	iter.first(&objToTest);
 
 	for (iter.first(&objToTest);
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 4662eec957..a8ad3aea57 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -1026,7 +1026,7 @@ int16 tileNopeHeight(
 GameObject *objectNollision(Effectron *obj, const TilePoint &loc) {
 //    ProtoObj        *proto = obj->proto();
 	TileRegion      volume;
-	GameObject      *obstacle;
+	GameObject      *obstacle = nullptr;
 
 	volume.min.u = loc.u - obj->brdCall();
 	volume.min.v = loc.v - obj->brdCall();
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index 20de8321e0..b8a7948b91 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -769,7 +769,7 @@ bool ObjectTarget::isObjectTarget(void) const {
 TilePoint ObjectTarget::where(GameWorld *world, const TilePoint &tp) const {
 	int16                   dist,
 	                        bestDist = maxint16;
-	GameObject     *objPtr;
+	GameObject     *objPtr = nullptr;
 	TilePoint               objCoords,
 	                        bestOCoords = Nowhere;
 	CircularObjectIterator  iter(world, tp, maxObjDist);
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 43698d804d..a37e307d69 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -533,7 +533,7 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
 	    world,
 	    instanceRegion.min,
 	    instanceRegion.max);
-	GameObject      *testObject;
+	GameObject *testObject = nullptr;
 
 	for (iter.first(&testObject);
 	        testObject != nullptr;
@@ -621,7 +621,7 @@ bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
 	    world,
 	    instanceRegion.min,
 	    instanceRegion.max);
-	GameObject      *testObject;
+	GameObject *testObject = nullptr;
 
 	for (iter.first(&testObject);
 	        testObject != nullptr;
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 400dc06365..7a9bfb108a 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -360,7 +360,7 @@ uint16 timeSinceLastAggressiveAct(void) {
 
 bool areThereActiveEnemies(void) {
 	ActiveRegionObjectIterator  iter;
-	GameObject                  *obj;
+	GameObject                  *obj = nullptr;
 
 	for (iter.first(&obj); obj != NULL; iter.next(&obj)) {
 		if (isActor(obj)




More information about the Scummvm-git-logs mailing list