From 786bcb0d1b95625c88e9c9b9cfe8bd1fe6e738fc Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 21 May 2017 19:30:00 +0300 Subject: [PATCH] rsx: bugfix - avoid a divide by zero --- rpcs3/Emu/RSX/Common/BufferUtils.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 1340ef3a02..5ad1198c9a 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -122,7 +122,9 @@ namespace //Count vertices to copy const bool is_128_aligned = !((dst_stride | src_stride) & 15); - const u32 min_block_size = std::min(src_stride, dst_stride); + u32 min_block_size = std::min(src_stride, dst_stride); + if (min_block_size == 0) min_block_size = dst_stride; + const u32 remainder = is_128_aligned? 0: (16 - min_block_size) / min_block_size; const u32 iterations = is_128_aligned? vertex_count: vertex_count - remainder; @@ -163,7 +165,9 @@ namespace const bool is_128_aligned = !((dst_stride | src_stride) & 15); - const u32 min_block_size = std::min(src_stride, dst_stride); + u32 min_block_size = std::min(src_stride, dst_stride); + if (min_block_size == 0) min_block_size = dst_stride; + const u32 remainder = is_128_aligned ? 0 : (16 - min_block_size) / min_block_size; const u32 iterations = is_128_aligned ? vertex_count : vertex_count - remainder;