1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-22 03:42:41 +01:00

Fix: potential division by 0 when drawing a line (#14994)

This commit is contained in:
Loïc Guilloux
2025-12-27 15:50:32 +01:00
committed by GitHub
parent a900f5656c
commit 42cffe0e16

View File

@@ -341,6 +341,9 @@ static inline void GfxDoDrawLine(void *video, int x, int y, int x2, int y2, int
margin *= 2; // account for rounding errors
}
/* Prevent division by zero. */
if (grade_x == 0) grade_x = 1;
/* Imagine that the line is infinitely long and it intersects with
* infinitely long left and right edges of the clipping rectangle.
* If both intersection points are outside the clipping rectangle