From c7486609fa26626beca76e1f018a120ee406f14d Mon Sep 17 00:00:00 2001 From: degasus Date: Thu, 9 May 2013 10:17:12 +0200 Subject: [PATCH] fix underflow in IndexGenerator::AddFan fix issue 6282 The Last Story seems to render a fan with two vertices. It is non-sense as it shouldn't do anything, but the code underflows at (u32)numVerts-3 --- Source/Core/VideoCommon/Src/IndexGenerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/VideoCommon/Src/IndexGenerator.cpp b/Source/Core/VideoCommon/Src/IndexGenerator.cpp index 15b2311f89..3970d8c82f 100644 --- a/Source/Core/VideoCommon/Src/IndexGenerator.cpp +++ b/Source/Core/VideoCommon/Src/IndexGenerator.cpp @@ -142,7 +142,7 @@ template void IndexGenerator::AddFan(u32 numVerts) if(pr) { - for(; i<=numVerts-3; i+=3) + for(; i+3<=numVerts; i+=3) { *Tptr++ = index + i - 1; *Tptr++ = index + i + 0; @@ -153,7 +153,7 @@ template void IndexGenerator::AddFan(u32 numVerts) numT += 3; } - for(; i<=numVerts-2; i+=2) + for(; i+2<=numVerts; i+=2) { *Tptr++ = index + i - 1; *Tptr++ = index + i + 0;