mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-30 13:21:04 +00:00
PCExhumed: Handle integer overflow in PlotCourseToSprite()
This commit is contained in:
parent
2a1ef00542
commit
80dd794550
1 changed files with 12 additions and 1 deletions
|
@ -677,7 +677,18 @@ int PlotCourseToSprite(int nSprite1, int nSprite2)
|
||||||
|
|
||||||
sprite[nSprite1].ang = GetMyAngle(x, y);
|
sprite[nSprite1].ang = GetMyAngle(x, y);
|
||||||
|
|
||||||
return ksqrt(y * y + x * x);
|
uint32_t x2 = klabs(x);
|
||||||
|
uint32_t y2 = klabs(y);
|
||||||
|
|
||||||
|
uint32_t diff = x2 * x2 + y2 * y2;
|
||||||
|
|
||||||
|
if (diff > INT_MAX)
|
||||||
|
{
|
||||||
|
OSD_Printf("%s %d: overflow\n", EDUKE32_FUNCTION, __LINE__);
|
||||||
|
diff = INT_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ksqrt(diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FindPlayer(int nSprite, int nDistance)
|
int FindPlayer(int nSprite, int nDistance)
|
||||||
|
|
Loading…
Reference in a new issue