Skip to content

Commit d96ad86

Browse files
committed
[GEN][ZH] Prevent using uninitialized memory 'offset_u' in W3DTankDraw, W3DTankTruckDraw
1 parent 6026f2c commit d96ad86

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,12 @@ void W3DTankDraw::updateTreadPositions(Real uvDelta)
234234
else
235235
if (pTread->m_type == TREAD_RIGHT) //this tread needs to scroll backwards
236236
offset_u = pTread->m_materialSettings.customUVOffset.X - uvDelta;
237-
237+
else
238+
{
239+
DEBUG_CRASH(("Unhandled case in W3DTankDraw::updateTreadPositions"));
240+
offset_u = 0.0f;
241+
}
242+
238243
// ensure coordinates of offset are in [0, 1] range:
239244
offset_u = offset_u - WWMath::Floor(offset_u);
240245
pTread->m_materialSettings.customUVOffset.Set(offset_u,0);

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,12 @@ void W3DTankTruckDraw::updateTreadPositions(Real uvDelta)
414414
else
415415
if (pTread->m_type == TREAD_RIGHT) //this tread needs to scroll backwards
416416
offset_u = pTread->m_materialSettings.customUVOffset.X - uvDelta;
417-
417+
else
418+
{
419+
DEBUG_CRASH(("Unhandled case in W3DTankTruckDraw::updateTreadPositions"));
420+
offset_u = 0.0f;
421+
}
422+
418423
// ensure coordinates of offset are in [0, 1] range:
419424
offset_u = offset_u - WWMath::Floor(offset_u);
420425
pTread->m_materialSettings.customUVOffset.Set(offset_u,0);

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,12 @@ void W3DTankDraw::updateTreadPositions(Real uvDelta)
234234
else
235235
if (pTread->m_type == TREAD_RIGHT) //this tread needs to scroll backwards
236236
offset_u = pTread->m_materialSettings.customUVOffset.X - uvDelta;
237-
237+
else
238+
{
239+
DEBUG_CRASH(("Unhandled case in W3DTankDraw::updateTreadPositions"));
240+
offset_u = 0.0f;
241+
}
242+
238243
// ensure coordinates of offset are in [0, 1] range:
239244
offset_u = offset_u - WWMath::Floor(offset_u);
240245
pTread->m_materialSettings.customUVOffset.Set(offset_u,0);

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,12 @@ void W3DTankTruckDraw::updateTreadPositions(Real uvDelta)
414414
else
415415
if (pTread->m_type == TREAD_RIGHT) //this tread needs to scroll backwards
416416
offset_u = pTread->m_materialSettings.customUVOffset.X - uvDelta;
417-
417+
else
418+
{
419+
DEBUG_CRASH(("Unhandled case in W3DTankTruckDraw::updateTreadPositions"));
420+
offset_u = 0.0f;
421+
}
422+
418423
// ensure coordinates of offset are in [0, 1] range:
419424
offset_u = offset_u - WWMath::Floor(offset_u);
420425
pTread->m_materialSettings.customUVOffset.Set(offset_u,0);

0 commit comments

Comments
 (0)