浏览代码

Fixed a few CWE-457

AlexVinS 9 年之前
父节点
当前提交
609c6f81bd
共有 7 个文件被更改,包括 19 次插入10 次删除
  1. 3 1
      lib/mapping/CMap.cpp
  2. 5 3
      lib/rmg/CMapGenerator.cpp
  3. 5 3
      lib/rmg/CZonePlacer.cpp
  4. 2 1
      lib/spells/CSpellHandler.cpp
  5. 2 0
      server/CGameHandler.cpp
  6. 0 1
      server/CGameHandler.h
  7. 2 1
      server/CQuery.cpp

+ 3 - 1
lib/mapping/CMap.cpp

@@ -217,7 +217,9 @@ CMapHeader::~CMapHeader()
 
 }
 
-CMap::CMap() : checksum(0), grailPos(-1, -1, -1), grailRadius(0), terrain(nullptr)
+CMap::CMap()
+	: checksum(0), grailPos(-1, -1, -1), grailRadius(0), terrain(nullptr),
+	guardingCreaturePositions(nullptr)
 {
 	allHeroes.resize(allowedHeroes.size());
 	allowedAbilities = VLC->heroh->getDefaultAllowedAbilities();

+ 5 - 3
lib/rmg/CMapGenerator.cpp

@@ -37,7 +37,9 @@ void CMapGenerator::foreachDirectNeighbour(const int3& pos, std::function<void(i
 
 
 CMapGenerator::CMapGenerator() :
-    zonesTotal(0), monolithIndex(0)
+	mapGenOptions(nullptr), randomSeed(0), editManager(nullptr),
+	zonesTotal(0), tiles(nullptr), prisonsRemaining(0),
+    monolithIndex(0)
 {
 }
 
@@ -639,7 +641,7 @@ void CMapGenerator::createConnections2()
 						}
 					}
 				}
-				if (!continueOuterLoop) //we didn't find ANY tile - break outer loop			
+				if (!continueOuterLoop) //we didn't find ANY tile - break outer loop
 					break;
 			}
 			if (!guardPos.valid()) //cleanup? is this safe / enough?
@@ -751,7 +753,7 @@ TRmgTemplateZoneId CMapGenerator::getZoneID(const int3& tile) const
 	return zoneColouring[tile.z][tile.x][tile.y];
 }
 
-void CMapGenerator::setZoneID(const int3& tile, TRmgTemplateZoneId zid) 
+void CMapGenerator::setZoneID(const int3& tile, TRmgTemplateZoneId zid)
 {
 	checkIsOnMap(tile);
 

+ 5 - 3
lib/rmg/CZonePlacer.cpp

@@ -24,7 +24,9 @@ CPlacedZone::CPlacedZone(const CRmgTemplateZone * zone)
 
 }
 
-CZonePlacer::CZonePlacer(CMapGenerator * Gen) : gen(Gen)
+CZonePlacer::CZonePlacer(CMapGenerator * Gen)
+	: width(0), height(0), scaleX(0), scaleY(0), mapSize(0), gravityConstant(0), stiffnessConstant(0),
+	gen(Gen)
 {
 
 }
@@ -153,7 +155,7 @@ void CZonePlacer::placeZones(const CMapGenOptions * mapGenOptions, CRandomGenera
 }
 
 void CZonePlacer::prepareZones(TZoneMap &zones, TZoneVector &zonesVector, const bool underground, CRandomGenerator * rand)
-{	
+{
 	std::vector<float> totalSize = { 0, 0 }; //make sure that sum of zone sizes on surface and uderground match size of the map
 
 	const float radius = 0.4f;
@@ -168,7 +170,7 @@ void CZonePlacer::prepareZones(TZoneMap &zones, TZoneVector &zonesVector, const
 
 	//first pass - determine fixed surface for zones
 	for (auto zone : zonesVector)
-	{	
+	{
 		if (!underground) //this step is ignored
 			zonesToPlace.push_back(zone);
 		else //place players depending on their factions

+ 2 - 1
lib/spells/CSpellHandler.cpp

@@ -95,10 +95,11 @@ CSpell::LevelInfo::~LevelInfo()
 ///CSpell
 CSpell::CSpell():
 	id(SpellID::NONE), level(0),
+	power(0),
 	combatSpell(false), creatureAbility(false),
 	positiveness(ESpellPositiveness::NEUTRAL),
 	defaultProbability(0),
-	isRising(false), isDamage(false), isOffensive(false),
+	isRising(false), isDamage(false), isOffensive(false), isSpecial(true),
 	targetType(ETargetType::NO_TARGET),
 	mechanics(),
 	adventureMechanics()

+ 2 - 0
server/CGameHandler.cpp

@@ -6277,6 +6277,8 @@ CGameHandler::FinishingBattleHelper::FinishingBattleHelper(std::shared_ptr<const
 CGameHandler::FinishingBattleHelper::FinishingBattleHelper()
 {
 	winnerHero = loserHero = nullptr;
+	duel = false;
+	remainingBattleQueriesCount = 0;
 }
 
 CRandomGenerator & CGameHandler::getRandomGenerator()

+ 0 - 1
server/CGameHandler.h

@@ -83,7 +83,6 @@ public:
 	enum EVisitDest {VISIT_DEST, DONT_VISIT_DEST};
 	enum ELEaveTile {LEAVING_TILE, REMAINING_ON_TILE};
 
-	CVCMIServer *s;
 	std::map<PlayerColor, CConnection*> connections; //player color -> connection to client with interface of that player
 	PlayerStatuses states; //player color -> player state
 	std::set<CConnection*> conns;

+ 2 - 1
server/CQuery.cpp

@@ -239,8 +239,9 @@ CBattleQuery::CBattleQuery(const BattleInfo *Bi)
 }
 
 CBattleQuery::CBattleQuery()
+	:bi(nullptr)
 {
-
+	belligerents[0] = belligerents[1] = nullptr;
 }
 
 bool CBattleQuery::blocksPack(const CPack *pack) const