changeset 32354:c3c2dd7042bf

gui: Avoid assertion error when selecting areas behind end of screen buffer. * libgui/qterminal/libqterminal/unix/Screen.cpp (Screen::copyLineToStream): Make sure that upper bound for character count is not below lower bound.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 27 Sep 2023 17:04:36 +0200
parents 9067c860e0f1
children bf77e0f86f74
files libgui/qterminal/libqterminal/unix/Screen.cpp
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/unix/Screen.cpp	Wed Sep 27 15:49:10 2023 +0200
+++ b/libgui/qterminal/libqterminal/unix/Screen.cpp	Wed Sep 27 17:04:36 2023 +0200
@@ -1381,8 +1381,8 @@
 		}
 		else
 		{
-			if ( count == -1 )
-					count = columns - start;
+            if ( count == -1 )
+              count = columns - start;
 
             assert( count >= 0 );
 
@@ -1391,14 +1391,14 @@
             Character* data = screenLines[screenLine].data();
             int length = screenLines[screenLine].count();
 
-			//retrieve line from screen image
-			for (int i=start;i < qMin(start+count,length);i++)
-			{
-			    characterBuffer[i-start] = data[i];
+            //retrieve line from screen image
+            for (int i=start; i < qMin(start+count,length); i++)
+            {
+                characterBuffer[i-start] = data[i];
             }
 
             // count cannot be any greater than length
-			count = qBound(0,count,length-start);
+            count = qBound (0, count, qMax (0, length-start));
 
             Q_ASSERT( screenLine < lineProperties.count() );
             currentLineProperties |= lineProperties[screenLine];