Prevent invalid image array indexing
ClosedPublic

Authored by mglb on Apr 26 2018, 9:52 PM.

Details

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

Diff Detail

Repository
R319 Konsole
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mglb requested review of this revision.Apr 26 2018, 9:52 PM
mglb created this revision.

Thanks, can confirm the crash and this patch fixes it. Let me do some more testing.

mglb updated this revision to Diff 33797.May 7 2018, 11:10 PM

git rebase master

Do you notice an extra blank column space on the far right of the terminal? With scrollbar on the right, there's a space between text and scrollbar.

mglb added a comment.May 10 2018, 12:38 AM

I've tried with custom and default konsole config, zsh with powerline as the shell. I don't have any additional space other than the area which is too narrow to be used as text column and part of the scrollbar. But those are normally there. I've tried displaying long text lines and long text lines + window scaling. TerminalCenter and TerminalMargin also works as in master.

Restricted Application added a subscriber: konsole-devel. · View Herald TranscriptMay 10 2018, 12:38 AM

OK maybe it just strange the first time seeing it when using the window size from the old code. I'll double-check again.

hindenburg accepted this revision.May 12 2018, 3:07 PM
This revision is now accepted and ready to land.May 12 2018, 3:07 PM
This revision was automatically updated to reflect the committed changes.

Some of the konsole/tests/boxes.txt look much worse after this commit. I tried various fonts.

Single width, double, triple and quadruple dash.
Double width, double, triple and quadruple dash.

mglb added a comment.May 14 2018, 6:57 AM

The boxes look the same for me, both on master and master + the patch reverted:


Font: Hack; also tested Ubuntu Mono. Checked in vim and cat.

Can you upload a screenshot?

I tested 4 different fonts; not sure what else would affect it.

Ok just remembered I changed my fonts.conf for some other testing; reverting it corrects the boxes.