From 39e362b21166f4768d8afc0c62f1ac3d30f687b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Sat, 27 Dec 2025 15:50:32 +0100 Subject: [PATCH] Fix: potential division by 0 when drawing a line (#14994) --- src/gfx.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gfx.cpp b/src/gfx.cpp index 817d08556c..12ba6a92a2 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -356,6 +356,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