Skip to content

Commit 812204a

Browse files
committed
Fix ASAN errors allowing exiting a race
1 parent cee3b15 commit 812204a

5 files changed

Lines changed: 10 additions & 9 deletions

File tree

GolDP/src/render/goldrawstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ LegoS32 GolDrawState::CreateDisplay(LegoS32 p_width, LegoS32 p_height, undefined
113113
// FUNCTION: GOLDP 0x1001d6d0
114114
void GolDrawState::Present()
115115
{
116-
m_displaySurface->Present(NULL);
116+
m_displaySurface->Present(0);
117117
}
118118

119119
// FUNCTION: GOLDP 0x1001d6e0

LEGORacers/src/race/racer/carvisuals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ void CarVisuals::UpdateDriver(LegoU32 p_elapsedMs)
863863
}
864864

865865
if (m_racer->m_lapsCompleted >= g_raceLapCount) {
866-
if (m_racer->m_lapTimes[5] == 1) {
866+
if (m_racer->m_standingsPosition == 1) {
867867
if (activePart == c_animationPart13 || activePart == c_animationPart15 || activePart == c_animationPart14) {
868868
return;
869869
}

LEGORacers/src/race/racestate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ LegoU32 RaceState::GetTimeBehind(Racer* p_racer)
10931093
return 0;
10941094
}
10951095

1096-
if (p_racer->m_lapTimes[5] == 1) {
1096+
if (p_racer->m_standingsPosition == 1) {
10971097
return 0;
10981098
}
10991099

@@ -1195,7 +1195,7 @@ void RaceState::ComputeStandingsDeltas(Racer* p_racer, Racer::StandingsDeltaEntr
11951195
entry->m_delta = otherTime - racerTime;
11961196
}
11971197
else {
1198-
entry->m_delta = otherRacer->m_lapTimes[5] + 2147483641;
1198+
entry->m_delta = otherRacer->m_standingsPosition + 2147483641;
11991199
}
12001200

12011201
racerIndex++;

common/src/goldecompress.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ LegoU32 GolDecompress(LegoU8* p_src, LegoU8* p_dst)
4343
dst++;
4444
} while (count != 0);
4545

46-
ctrl *= 2;
46+
// Overflow of a signed integer is undefined behavior, so cast to a unsigned one.
47+
ctrl = static_cast<LegoS32>(2 * static_cast<LegoU32>(ctrl));
4748
if (!(ctrl & 0xff)) {
4849
break;
4950
}

common/src/golnametable.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ void GolNameTable::AddName(const LegoChar* p_name, void* p_value)
6161
break;
6262
}
6363

64-
startIndex += c << shift;
64+
startIndex += static_cast<LegoU32>(c) << shift;
6565
shift += 7;
66-
shift &= 0x1f;
66+
shift %= 32;
6767
}
6868

6969
startIndex %= m_capacity;
@@ -105,9 +105,9 @@ void* GolNameTable::GetName(const LegoChar* p_name) const
105105
break;
106106
}
107107

108-
startIndex += c << shift;
108+
startIndex += static_cast<LegoU32>(c) << shift;
109109
shift += 7;
110-
shift &= 0x1f;
110+
shift %= 32;
111111
}
112112

113113
startIndex %= m_capacity;

0 commit comments

Comments
 (0)