summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-05-03 13:44:42 +0000
committerrodri <rgl@antares-labs.eu>2024-05-03 13:44:42 +0000
commitafc811ce9e8b8a1a3d83b3855f4a9e63ba5a2c7b (patch)
tree1750d2802cebb26a5f22f442910db6045ce64605
parentb429311ed087ee7cf7fc7771a8e1834ea074f8da (diff)
downloadlibgraphics-afc811ce9e8b8a1a3d83b3855f4a9e63ba5a2c7b.tar.gz
libgraphics-afc811ce9e8b8a1a3d83b3855f4a9e63ba5a2c7b.tar.bz2
libgraphics-afc811ce9e8b8a1a3d83b3855f4a9e63ba5a2c7b.zip
clip: avoid division by zero.
-rw-r--r--clip.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/clip.c b/clip.c
index ded387b..82b15ea 100644
--- a/clip.c
+++ b/clip.c
@@ -208,11 +208,11 @@ rectclipline(Rectangle r, Point *p0, Point *p1)
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;
}