summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Software/EfbInterface.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2021-04-23 14:07:46 -0400
committerGitHub <noreply@github.com>2021-04-23 14:07:46 -0400
commitcfc4af76a9d0b00df81239d9a83ba5ea1d381a1e (patch)
tree0e1640a5792c970f4b6547f5f46ad689b48a8c8b /Source/Core/VideoBackends/Software/EfbInterface.cpp
parent4ab92d47574aa2388d39d6740ac85cc3324a15b8 (diff)
parent058c7db80b074fa52aaa504329ee69cf25a516e3 (diff)
Merge pull request #9321 from Pokechu22/sw-copyregion
Software: Fix out of bounds accesses in CopyRegion
Diffstat (limited to 'Source/Core/VideoBackends/Software/EfbInterface.cpp')
-rw-r--r--Source/Core/VideoBackends/Software/EfbInterface.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp
index 8ef62d5b03..acf82fc317 100644
--- a/Source/Core/VideoBackends/Software/EfbInterface.cpp
+++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp
@@ -634,17 +634,13 @@ void EncodeXFB(u8* xfb_in_ram, u32 memory_stride, const MathUtil::Rectangle<int>
src_ptr += memory_stride;
}
- auto dest_rect =
- MathUtil::Rectangle<int>{source_rect.left, source_rect.top, source_rect.right,
- static_cast<int>(static_cast<float>(source_rect.bottom) * y_scale)};
+ const int src_width = source_rect.GetWidth();
+ const int src_height = source_rect.GetHeight();
+ const int dst_width = src_width;
+ const int dst_height = src_height * y_scale;
- const std::size_t destination_size = dest_rect.GetWidth() * dest_rect.GetHeight() * 2;
- static std::vector<yuv422_packed> destination;
- destination.resize(dest_rect.GetWidth() * dest_rect.GetHeight());
-
- SW::CopyRegion(source.data(), source_rect, destination.data(), dest_rect);
-
- memcpy(xfb_in_ram, destination.data(), destination_size);
+ SW::CopyRegion(source.data(), src_width, src_height, reinterpret_cast<yuv422_packed*>(xfb_in_ram),
+ dst_width, dst_height);
}
bool ZCompare(u16 x, u16 y, u32 z)