From 4354e98908dcdddf965e2a893f04fb343dc39aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Mon, 3 Jun 2019 18:44:53 +0200 Subject: [PATCH] Fix segfault --- small3dlib.h | 3 ++- testSDL.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/small3dlib.h b/small3dlib.h index b6d93ec..bc5eb73 100644 --- a/small3dlib.h +++ b/small3dlib.h @@ -1531,7 +1531,8 @@ void S3L_drawTriangle( loop */ #endif - if (rXClipped < lXClipped) + if (rXClipped < lXClipped && + lXClipped < S3L_RESOLUTION_X && rXClipped >= 0) { /* This can sometimes happen because of numerical errors in sorting left vs right triangle point, which are compared based on SLOPE, not diff --git a/testSDL.c b/testSDL.c index 0ef8922..31567f2 100644 --- a/testSDL.c +++ b/testSDL.c @@ -18,8 +18,8 @@ #define S3L_PIXEL_FUNCTION drawPixel -#define S3L_RESOLUTION_X 110 -#define S3L_RESOLUTION_Y 88 +#define S3L_RESOLUTION_X 640 +#define S3L_RESOLUTION_Y 480 #include "small3dlib.h"