GRAPHICS: Fix possible out of bound write for 1bpp blit in ManagedSurface

This commit is contained in:
Thierry Crozat 2021-03-16 23:44:56 +00:00
parent b40541d0fb
commit 7ec6215547

View File

@ -279,7 +279,16 @@ void ManagedSurface::blitFromInner(const Surface &src, const Common::Rect &srcRe
// For paletted format, assume the palette is the same and there is no transparency.
// We can thus do a straight copy of the pixels.
if (format.bytesPerPixel == 1 && noScale) {
Common::copy(srcP, srcP + srcRect.width() * format.bytesPerPixel, destP);
int width = srcRect.width();
if (destRect.left + width > w)
width = w - destRect.left;
if (destRect.left < 0) {
srcP -= destRect.left;
destP -= destRect.left;
width += destRect.left;
}
if (width > 0)
Common::copy(srcP, srcP + width, destP);
continue;
}