sw_engine: Fix buffer overflow in texture mapping rasterizer

Fix heap buffer overflow in texture mapping rasterizer by adding proper
bounds checking for texture coordinates. This prevents accessing memory
outside of the allocated image buffer during texture sampling and
interpolation.
This commit is contained in:
Jinny You 2025-01-09 16:30:49 +08:00
parent 3d6fe5ffae
commit 50a0df805f

View file

@ -336,9 +336,9 @@ static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image,
//Draw horizontal line //Draw horizontal line
while (x++ < x2) { while (x++ < x2) {
uu = (int) u; uu = (int) u;
if (uu >= sw) continue; if (uu < 0 || uu >= sw) continue;
vv = (int) v; vv = (int) v;
if (vv >= sh) continue; if (vv < 0 || vv >= sh) continue;
ar = (int)(255.0f * (1.0f - modff(u, &iptr))); ar = (int)(255.0f * (1.0f - modff(u, &iptr)));
ab = (int)(255.0f * (1.0f - modff(v, &iptr))); ab = (int)(255.0f * (1.0f - modff(v, &iptr)));