diff options
| author | Pokechu22 <Pokechu022@gmail.com> | 2020-12-11 23:04:32 -0800 |
|---|---|---|
| committer | Pokechu22 <Pokechu022@gmail.com> | 2021-03-06 21:58:28 -0800 |
| commit | 058c7db80b074fa52aaa504329ee69cf25a516e3 (patch) | |
| tree | 9fc4a04fe7968f632461d33f80191e44eaec8b87 /Source/Core/VideoBackends/Software/SWTexture.cpp | |
| parent | 089250fde65c2e225681c0ef6917d28fa187e8de (diff) | |
Software: Fix out of bounds accesses in CopyRegion
Fixes issue 11393.
The problem is that left and top make no sense for a width by height array; they only make sense in a larger array where from which a smaller part is extracted. Thus, the overall size of the array is provided to CopyRegion in addition to the sub-region. EncodeXFB already handles the extraction, so CopyRegion's only use there is to resize the image (and thus no sub-region is provided).
Diffstat (limited to 'Source/Core/VideoBackends/Software/SWTexture.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Software/SWTexture.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/Source/Core/VideoBackends/Software/SWTexture.cpp b/Source/Core/VideoBackends/Software/SWTexture.cpp index 466da1efd5..eda833c56f 100644 --- a/Source/Core/VideoBackends/Software/SWTexture.cpp +++ b/Source/Core/VideoBackends/Software/SWTexture.cpp @@ -56,15 +56,10 @@ void SWRenderer::ScaleTexture(AbstractFramebuffer* dst_framebuffer, const SWTexture* software_source_texture = static_cast<const SWTexture*>(src_texture); SWTexture* software_dest_texture = static_cast<SWTexture*>(dst_framebuffer->GetColorAttachment()); - std::vector<Pixel> source_pixels; - source_pixels.resize(src_rect.GetHeight() * src_rect.GetWidth() * 4); - memcpy(source_pixels.data(), software_source_texture->GetData(), source_pixels.size()); - - std::vector<Pixel> destination_pixels; - destination_pixels.resize(dst_rect.GetHeight() * dst_rect.GetWidth() * 4); - - CopyRegion(source_pixels.data(), src_rect, destination_pixels.data(), dst_rect); - memcpy(software_dest_texture->GetData(), destination_pixels.data(), destination_pixels.size()); + CopyRegion(reinterpret_cast<const Pixel*>(software_source_texture->GetData()), src_rect, + src_texture->GetWidth(), src_texture->GetHeight(), + reinterpret_cast<Pixel*>(software_dest_texture->GetData()), dst_rect, + dst_framebuffer->GetWidth(), dst_framebuffer->GetHeight()); } SWTexture::SWTexture(const TextureConfig& tex_config) : AbstractTexture(tex_config) |
