From a08c73b08bf7e5ef147735e4e6e45096584b4777 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Wed, 21 Aug 2024 02:29:53 +0200 Subject: [PATCH] sw_engine: fix TexmapPolygon rastering The y range initialization was missing a check to ensure that the height is a positive value. This could lead to an attempt to call malloc with a negative argument, which cast to an unsigned value, caused a crash. --- src/renderer/sw_engine/tvgSwRasterTexmap.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/renderer/sw_engine/tvgSwRasterTexmap.h b/src/renderer/sw_engine/tvgSwRasterTexmap.h index 6c562a0e..229e7e1d 100644 --- a/src/renderer/sw_engine/tvgSwRasterTexmap.h +++ b/src/renderer/sw_engine/tvgSwRasterTexmap.h @@ -53,12 +53,10 @@ static bool _arrange(const SwImage* image, const SwBBox* region, int& yStart, in regionBottom = image->rle->spans[image->rle->size - 1].y; } - if (yStart >= regionBottom) return false; - if (yStart < regionTop) yStart = regionTop; if (yEnd > regionBottom) yEnd = regionBottom; - return true; + return yEnd > yStart; }