mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
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).
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user