shithub: libgraphics

Download patch

ref: afc811ce9e8b8a1a3d83b3855f4a9e63ba5a2c7b
parent: b429311ed087ee7cf7fc7771a8e1834ea074f8da
author: rodri <rgl@antares-labs.eu>
date: Fri May 3 09:44:42 EDT 2024

clip: avoid division by zero.

--- a/clip.c
+++ b/clip.c
@@ -208,11 +208,11 @@
 			p0->y += (r.max.x - p0->x)*m;
 			p0->x = r.max.x;
 		}else if(code0 & CLIPB){
-			if(p0->x != p1->x)
+			if(p0->x != p1->x && m != 0)
 				p0->x += (r.min.y - p0->y)/m;
 			p0->y = r.min.y;
 		}else if(code0 & CLIPT){
-			if(p0->x != p1->x)
+			if(p0->x != p1->x && m != 0)
 				p0->x += (r.max.y - p0->y)/m;
 			p0->y = r.max.y;
 		}