Prevent invalid image array indexing
Summary:
Fixed cases mainly come from the fact that ScreenWindow can be
larger that TerminalDisplay's image, and the way how selection area is
bounded (character's left edge, not first/last character in selection).
Test Plan:
- Compile with ASAN
- Turn on blinking cursor
- Slowly change window size to less than 1 line or less than 1 column
- If everything is still ok, run top or anything that generates longer output
Expected result: no overflows
- Random selections (normal/block/line/word):
- on screen in left/right direction
- on screen + in history
- selecting history up
- selecting history down
- first/last character → last/first character in the line
- first/last character → last/first character on the screen
- all above with wide characters
Reviewers: Konsole, hindenburg
Reviewed By: Konsole, hindenburg
Subscribers: konsole-devel, hindenburg, Konsole
Tags: Konsole
Differential Revision: https://phabricator.kde.org/D12551