Skip to content

Commit be7f0d4

Browse files
authored
[GEN][ZH] Prevent using uninitialized memory 'result' in PartitionData::calcMaxCoiForShape() (#1133)
1 parent e42d4e4 commit be7f0d4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Generals/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,8 +2168,12 @@ Int PartitionData::calcMaxCoiForShape(GeometryType geom, Real majorRadius, Real
21682168
Real diagonal = (Real)(sqrtf(majorRadius*majorRadius + minorRadius*minorRadius));
21692169
Int cells = ThePartitionManager->worldToCellDist(diagonal*2) + 1;
21702170
result = cells * cells;
2171+
break;
21712172
}
2173+
default:
2174+
return 4;
21722175
};
2176+
static_assert(GEOMETRY_NUM_TYPES == 3, "GEOMETRY_NUM_TYPES has changed");
21732177
}
21742178
if (result < 4)
21752179
result = 4;

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,8 +2175,12 @@ Int PartitionData::calcMaxCoiForShape(GeometryType geom, Real majorRadius, Real
21752175
Real diagonal = (Real)(sqrtf(majorRadius*majorRadius + minorRadius*minorRadius));
21762176
Int cells = ThePartitionManager->worldToCellDist(diagonal*2) + 1;
21772177
result = cells * cells;
2178+
break;
21782179
}
2180+
default:
2181+
return 4;
21792182
};
2183+
static_assert(GEOMETRY_NUM_TYPES == 3, "GEOMETRY_NUM_TYPES has changed");
21802184
}
21812185
if (result < 4)
21822186
result = 4;

0 commit comments

Comments
 (0)