sw_engine texmap: fixed a memory violation.

A reported out-of-range memory access issue,
as identified by the sanitizer, has been corrected.
This commit is contained in:
Hermet Park 2023-07-28 23:29:42 +09:00 committed by Hermet Park
parent 229efd7807
commit 65189ab8e8

View file

@ -154,14 +154,15 @@ static void _rasterMaskedPolygonImageSegmentInt(SwSurface* surface, const SwImag
} else { } else {
if (opacity == 255) { if (opacity == 255) {
uu = (int) u; uu = (int) u;
if (uu >= sw) continue;
vv = (int) v; vv = (int) v;
if (vv >= sh) continue;
ar = (int)(255 * (1 - modff(u, &iptr))); ar = (int)(255 * (1 - modff(u, &iptr)));
ab = (int)(255 * (1 - modff(v, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr)));
iru = uu + 1; iru = uu + 1;
irv = vv + 1; irv = vv + 1;
if (vv >= sh) continue;
px = *(sbuf + (vv * sw) + uu); px = *(sbuf + (vv * sw) + uu);
/* horizontal interpolate */ /* horizontal interpolate */
@ -190,14 +191,15 @@ static void _rasterMaskedPolygonImageSegmentInt(SwSurface* surface, const SwImag
v += _dvdx; v += _dvdx;
} else { } else {
uu = (int) u; uu = (int) u;
if (uu >= sw) continue;
vv = (int) v; vv = (int) v;
if (vv >= sh) continue;
ar = (int)(255 * (1 - modff(u, &iptr))); ar = (int)(255 * (1 - modff(u, &iptr)));
ab = (int)(255 * (1 - modff(v, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr)));
iru = uu + 1; iru = uu + 1;
irv = vv + 1; irv = vv + 1;
if (vv >= sh) continue;
px = *(sbuf + (vv * sw) + uu); px = *(sbuf + (vv * sw) + uu);
/* horizontal interpolate */ /* horizontal interpolate */
@ -317,15 +319,15 @@ static void _rasterMaskedPolygonImageSegmentDup(SwSurface* surface, const SwImag
//Draw horizontal line //Draw horizontal line
while (x++ < x2) { while (x++ < x2) {
uu = (int) u; uu = (int) u;
if (uu >= sw) continue;
vv = (int) v; vv = (int) v;
if (vv >= sh) continue;
ar = (int)(255 * (1 - modff(u, &iptr))); ar = (int)(255 * (1 - modff(u, &iptr)));
ab = (int)(255 * (1 - modff(v, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr)));
iru = uu + 1; iru = uu + 1;
irv = vv + 1; irv = vv + 1;
if (vv >= sh) continue;
px = *(sbuf + (vv * sw) + uu); px = *(sbuf + (vv * sw) + uu);
/* horizontal interpolate */ /* horizontal interpolate */
@ -360,15 +362,15 @@ static void _rasterMaskedPolygonImageSegmentDup(SwSurface* surface, const SwImag
//Draw horizontal line //Draw horizontal line
while (x++ < x2) { while (x++ < x2) {
uu = (int) u; uu = (int) u;
if (uu >= sw) continue;
vv = (int) v; vv = (int) v;
if (vv >= sh) continue;
ar = (int)(255 * (1 - modff(u, &iptr))); ar = (int)(255 * (1 - modff(u, &iptr)));
ab = (int)(255 * (1 - modff(v, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr)));
iru = uu + 1; iru = uu + 1;
irv = vv + 1; irv = vv + 1;
if (vv >= sh) continue;
px = *(sbuf + (vv * sw) + uu); px = *(sbuf + (vv * sw) + uu);
/* horizontal interpolate */ /* horizontal interpolate */
@ -504,15 +506,15 @@ static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage
//Draw horizontal line //Draw horizontal line
while (x++ < x2) { while (x++ < x2) {
uu = (int) u; uu = (int) u;
if (uu >= sw) continue;
vv = (int) v; vv = (int) v;
if (vv >= sh) continue;
ar = (int)(255 * (1 - modff(u, &iptr))); ar = (int)(255 * (1 - modff(u, &iptr)));
ab = (int)(255 * (1 - modff(v, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr)));
iru = uu + 1; iru = uu + 1;
irv = vv + 1; irv = vv + 1;
if (vv >= sh) continue;
px = *(sbuf + (vv * sw) + uu); px = *(sbuf + (vv * sw) + uu);
/* horizontal interpolate */ /* horizontal interpolate */
@ -547,15 +549,15 @@ static void _rasterBlendingPolygonImageSegment(SwSurface* surface, const SwImage
//Draw horizontal line //Draw horizontal line
while (x++ < x2) { while (x++ < x2) {
uu = (int) u; uu = (int) u;
if (uu >= sw) continue;
vv = (int) v; vv = (int) v;
if (vv >= sh) continue;
ar = (int)(255 * (1 - modff(u, &iptr))); ar = (int)(255 * (1 - modff(u, &iptr)));
ab = (int)(255 * (1 - modff(v, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr)));
iru = uu + 1; iru = uu + 1;
irv = vv + 1; irv = vv + 1;
if (vv >= sh) continue;
px = *(sbuf + (vv * sw) + uu); px = *(sbuf + (vv * sw) + uu);
/* horizontal interpolate */ /* horizontal interpolate */
@ -688,15 +690,15 @@ 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;
vv = (int) v; vv = (int) v;
if (vv >= sh) continue;
ar = (int)(255 * (1 - modff(u, &iptr))); ar = (int)(255 * (1 - modff(u, &iptr)));
ab = (int)(255 * (1 - modff(v, &iptr))); ab = (int)(255 * (1 - modff(v, &iptr)));
iru = uu + 1; iru = uu + 1;
irv = vv + 1; irv = vv + 1;
if (vv >= sh) continue;
px = *(sbuf + (vv * sw) + uu); px = *(sbuf + (vv * sw) + uu);
/* horizontal interpolate */ /* horizontal interpolate */