all repos — mgba @ f184b8a315b2d19e3ee03e2914ab75946ba5904e

mGBA Game Boy Advance Emulator

DS GX: Fix another polygon overflow
Vicki Pfau vi@endrift.com
Wed, 29 Jul 2020 18:58:10 -0700
commit

f184b8a315b2d19e3ee03e2914ab75946ba5904e

parent

ec626d723fbb4716a697ad3cac0b0b29943dba00

1 files changed, 6 insertions(+), 0 deletions(-)

jump to
M src/ds/gx.csrc/ds/gx.c

@@ -322,6 +322,7 @@ }

return true; } + // Clip planes struct DSGXVertex inList[10]; struct DSGXVertex outList[10]; int outOffscreenVerts[10] = { 0, 0, 0, 0 };

@@ -340,6 +341,7 @@ mLOG(DS_GX, ERROR, "Polygon clipping invariant failed");

return false; } if (!(offscreenVerts[v] & (1 << plane))) { + // This vertex doesn't need clipping outList[newV] = inList[v]; outOffscreenVerts[newV] = offscreenVerts[v]; ++newV;

@@ -369,6 +371,10 @@ } else {

iv = 0; } if (!(offscreenVerts[iv] & (1 << plane))) { + if (newV >= 10) { + mLOG(DS_GX, ERROR, "Polygon clipping invariant failed"); + return false; + } in2 = &inList[iv]; out = &outList[newV]; if (_lerpVertexP(in, in2, out, plane >> 1, -1 + (plane & 1) * 2)) {