Skip to content

Commit

Permalink
Incorrect calculation of random ints
Browse files Browse the repository at this point in the history
Incorrect calculation of random integers was causing random overflows
and crashes, particularly when a Spectre was being rendered.
  • Loading branch information
bradharding committed Jan 27, 2014
1 parent e4c2b58 commit 4460187
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/m_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int M_Random(void)

int M_RandomInt(int lower, int upper)
{
return (rand() % (upper + 1) + lower);
return (rand() % (upper - lower + 1) + lower);
}

void M_ClearRandom (void)
Expand Down

0 comments on commit 4460187

Please sign in to comment.