From 0bdea48b9b67d2ad816304b130920d59b8e7172d Mon Sep 17 00:00:00 2001 From: Elias Batek Date: Tue, 8 Oct 2024 00:21:53 +0200 Subject: [PATCH] Fix bidirectional features of SubPixmapScanner --- pixmappaint.d | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pixmappaint.d b/pixmappaint.d index 72c6ce0..91ccefc 100644 --- a/pixmappaint.d +++ b/pixmappaint.d @@ -1056,7 +1056,12 @@ struct SubPixmapScanner { /// void popBack() { - _data = _data[0 .. ($ - _width)]; + if (_data.length < _feed) { + _data.length = 0; + return; + } + + _data = _data[0 .. ($ - _feed)]; } } @@ -1116,7 +1121,12 @@ struct SubPixmapScannerRW { /// void popBack() { - _data = _data[0 .. ($ - _width)]; + if (_data.length < _feed) { + _data.length = 0; + return; + } + + _data = _data[0 .. ($ - _feed)]; } }