https://git.reactos.org/?p=reactos.git;a=commitdiff;h=40f7e863472d2b0a662c06a95316997ab7c62d2b
commit 40f7e863472d2b0a662c06a95316997ab7c62d2b Author: Jérôme Gardou <jerome.gar...@reactos.org> AuthorDate: Wed Mar 31 16:55:30 2021 +0200 Commit: Jérôme Gardou <jerome.gar...@reactos.org> CommitDate: Wed Mar 31 16:55:30 2021 +0200 [WIN32K] Fix brain-fail of mine Copying e.g. (2;2);(6;6) to (0;0);(4;4) also needs to have an intermediate buffer. --- win32ss/gdi/dib/dib1bpp.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/win32ss/gdi/dib/dib1bpp.c b/win32ss/gdi/dib/dib1bpp.c index 0bc25777f0c..6dcc444baec 100644 --- a/win32ss/gdi/dib/dib1bpp.c +++ b/win32ss/gdi/dib/dib1bpp.c @@ -69,6 +69,7 @@ DIB_1BPP_BitBltSrcCopy_From1BPP ( LONG Width = RECTL_lGetWidth(DestRect); BOOLEAN XorBit = !!XLATEOBJ_iXlate(pxlo, 0); BOOLEAN Overlap = FALSE; + BYTE *DstStart, *DstEnd, *SrcStart, *SrcEnd; /* Make sure this is as expected */ ASSERT(DestRect->left >= 0); @@ -78,34 +79,30 @@ DIB_1BPP_BitBltSrcCopy_From1BPP ( /* * Check if we need to allocate a buffer for our operation. - * NB: if we're not mirroring, we're doing a memmove-like operation, so this is always fine. */ - if (bTopToBottom || bLeftToRight) - { - BYTE* DstStart = (BYTE*)DestSurf->pvScan0 + DestRect->top * DestSurf->lDelta + DestRect->left / 8; - BYTE* DstEnd = (BYTE*)DestSurf->pvScan0 + (DestRect->bottom - 1) * DestSurf->lDelta + (DestRect->right) / 8; - BYTE* SrcStart = (BYTE*)SourceSurf->pvScan0 + SourcePoint->y * SourceSurf->lDelta + SourcePoint->x / 8; - BYTE* SrcEnd = (BYTE*)SourceSurf->pvScan0 + (SourcePoint->y + Height - 1) * SourceSurf->lDelta + (SourcePoint->x + Width) / 8; + DstStart = (BYTE*)DestSurf->pvScan0 + DestRect->top * DestSurf->lDelta + DestRect->left / 8; + DstEnd = (BYTE*)DestSurf->pvScan0 + (DestRect->bottom - 1) * DestSurf->lDelta + (DestRect->right) / 8; + SrcStart = (BYTE*)SourceSurf->pvScan0 + SourcePoint->y * SourceSurf->lDelta + SourcePoint->x / 8; + SrcEnd = (BYTE*)SourceSurf->pvScan0 + (SourcePoint->y + Height - 1) * SourceSurf->lDelta + (SourcePoint->x + Width) / 8; - /* Beware of bitmaps with negative pitch! */ - if (DstStart > DstEnd) - { - BYTE* tmp = DstStart; - DstStart = DstEnd; - DstEnd = tmp; - } - - if (SrcStart > SrcEnd) - { - BYTE* tmp = SrcStart; - SrcStart = SrcEnd; - SrcEnd = tmp; - } + /* Beware of bitmaps with negative pitch! */ + if (DstStart > DstEnd) + { + BYTE* tmp = DstStart; + DstStart = DstEnd; + DstEnd = tmp; + } - /* We allocate a new buffer when the two buffers overlap */ - Overlap = ((SrcStart >= DstStart) && (SrcStart < DstEnd)) || ((SrcEnd >= DstStart) && (SrcEnd < DstEnd)); + if (SrcStart > SrcEnd) + { + BYTE* tmp = SrcStart; + SrcStart = SrcEnd; + SrcEnd = tmp; } + /* We allocate a new buffer when the two buffers overlap */ + Overlap = ((SrcStart >= DstStart) && (SrcStart < DstEnd)) || ((SrcEnd >= DstStart) && (SrcEnd < DstEnd)); + if (!Overlap) { LONG y;