diff --git a/src/gfx.cpp b/src/gfx.cpp index 950ef25484..9d05ce8d86 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -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