Skip to content

Commit

Permalink
Fixes UB in caps.c (#5878)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine authored Dec 25, 2024
1 parent 878724c commit 816d302
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ u32 GetSoftLevelCapExpValue(u32 level, u32 expValue)
if (B_LEVEL_CAP_EXP_UP)
{
levelDifference = currentLevelCap - level;
if (levelDifference > ARRAY_COUNT(sExpScalingUp))
if (levelDifference > ARRAY_COUNT(sExpScalingUp) - 1)
return expValue + (expValue / sExpScalingUp[ARRAY_COUNT(sExpScalingUp) - 1]);
else
return expValue + (expValue / sExpScalingUp[levelDifference]);
Expand All @@ -71,7 +71,7 @@ u32 GetSoftLevelCapExpValue(u32 level, u32 expValue)
else if (B_EXP_CAP_TYPE == EXP_CAP_SOFT)
{
levelDifference = level - currentLevelCap;
if (levelDifference > ARRAY_COUNT(sExpScalingDown))
if (levelDifference > ARRAY_COUNT(sExpScalingDown) - 1)
return expValue / sExpScalingDown[ARRAY_COUNT(sExpScalingDown) - 1];
else
return expValue / sExpScalingDown[levelDifference];
Expand Down

0 comments on commit 816d302

Please sign in to comment.