From 65189ab8e8368343d983b83cc1e1300d5857d87a Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 28 Jul 2023 23:29:42 +0900 Subject: [PATCH] sw_engine texmap: fixed a memory violation. A reported out-of-range memory access issue, as identified by the sanitizer, has been corrected. --- src/lib/sw_engine/tvgSwRasterTexmap.h | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/lib/sw_engine/tvgSwRasterTexmap.h b/src/lib/sw_engine/tvgSwRasterTexmap.h index 4074a0e0..4b30c52e 100644 --- a/src/lib/sw_engine/tvgSwRasterTexmap.h +++ b/src/lib/sw_engine/tvgSwRasterTexmap.h @@ -154,14 +154,15 @@ static void _rasterMaskedPolygonImageSegmentInt(SwSurface* surface, const SwImag } else { if (opacity == 255) { uu = (int) u; + if (uu >= sw) continue; vv = (int) v; + if (vv >= sh) continue; + ar = (int)(255 * (1 - modff(u, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr))); iru = uu + 1; irv = vv + 1; - if (vv >= sh) continue; - px = *(sbuf + (vv * sw) + uu); /* horizontal interpolate */ @@ -190,14 +191,15 @@ static void _rasterMaskedPolygonImageSegmentInt(SwSurface* surface, const SwImag v += _dvdx; } else { uu = (int) u; + if (uu >= sw) continue; vv = (int) v; + if (vv >= sh) continue; + ar = (int)(255 * (1 - modff(u, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr))); iru = uu + 1; irv = vv + 1; - if (vv >= sh) continue; - px = *(sbuf + (vv * sw) + uu); /* horizontal interpolate */ @@ -317,15 +319,15 @@ static void _rasterMaskedPolygonImageSegmentDup(SwSurface* surface, const SwImag //Draw horizontal line while (x++ < x2) { uu = (int) u; + if (uu >= sw) continue; vv = (int) v; + if (vv >= sh) continue; ar = (int)(255 * (1 - modff(u, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr))); iru = uu + 1; irv = vv + 1; - if (vv >= sh) continue; - px = *(sbuf + (vv * sw) + uu); /* horizontal interpolate */ @@ -360,15 +362,15 @@ static void _rasterMaskedPolygonImageSegmentDup(SwSurface* surface, const SwImag //Draw horizontal line while (x++ < x2) { uu = (int) u; + if (uu >= sw) continue; vv = (int) v; + if (vv >= sh) continue; ar = (int)(255 * (1 - modff(u, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr))); iru = uu + 1; irv = vv + 1; - if (vv >= sh) continue; - px = *(sbuf + (vv * sw) + uu); /* horizontal interpolate */ @@ -504,15 +506,15 @@ static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage //Draw horizontal line while (x++ < x2) { uu = (int) u; + if (uu >= sw) continue; vv = (int) v; + if (vv >= sh) continue; ar = (int)(255 * (1 - modff(u, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr))); iru = uu + 1; irv = vv + 1; - if (vv >= sh) continue; - px = *(sbuf + (vv * sw) + uu); /* horizontal interpolate */ @@ -547,15 +549,15 @@ static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage //Draw horizontal line while (x++ < x2) { uu = (int) u; + if (uu >= sw) continue; vv = (int) v; + if (vv >= sh) continue; ar = (int)(255 * (1 - modff(u, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr))); iru = uu + 1; irv = vv + 1; - if (vv >= sh) continue; - px = *(sbuf + (vv * sw) + uu); /* horizontal interpolate */ @@ -688,15 +690,15 @@ static void _rasterPolygonImageSegment(SwSurface* surface, const SwImage* image, //Draw horizontal line while (x++ < x2) { uu = (int) u; + if (uu >= sw) continue; vv = (int) v; + if (vv >= sh) continue; ar = (int)(255 * (1 - modff(u, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr))); iru = uu + 1; irv = vv + 1; - if (vv >= sh) continue; - px = *(sbuf + (vv * sw) + uu); /* horizontal interpolate */