From 6ef3626599631fb35a4f1f2245c12afeacf35123 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 19 Apr 2020 14:34:17 +1000 Subject: [PATCH] GPU/HW: Fix a possible crash in rectangle expansion --- src/core/gpu_hw.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 17e236763..faf31004e 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -308,8 +308,8 @@ void GPU_HW::LoadVertices() } // we can split the rectangle up into potentially 8 quads - const u32 required_vertices = 6 * ((rectangle_width + (TEXTURE_PAGE_WIDTH - 1)) / TEXTURE_PAGE_WIDTH) * - ((rectangle_height + (TEXTURE_PAGE_HEIGHT - 1)) / TEXTURE_PAGE_HEIGHT); + const u32 required_vertices = 6 * (((rectangle_width + (TEXTURE_PAGE_WIDTH - 1)) / TEXTURE_PAGE_WIDTH) + 1u) * + (((rectangle_height + (TEXTURE_PAGE_HEIGHT - 1)) / TEXTURE_PAGE_HEIGHT) + 1u); EnsureVertexBufferSpace(required_vertices); // Split the rectangle into multiple quads if it's greater than 256x256, as the texture page should repeat.