Move search line upper bound check to less generic function

Authored by mglb on Jul 14 2018, 12:34 AM.

Description

Move search line upper bound check to less generic function

Summary:
When there was at least one search attempt, search box is still opened,
and the screen and/or history is cleared, there is a high chance that
the line number remembered by the search is invalid. The line number is
used as the lines array index, so this can lead to overflow and crash.

This is at this moment fixed with a check in copyLineToStream(), which
is a generic function that happens to be used by search function and
where the line number is used. There still is an assert which is
triggered in debug builds.

The patch moves the check directly to a search function, where the line
number is initialized before first search.

Test Plan:
You have to do the test in debug build - there is a hack in
copyLineToStream() which prevents crash, but assert before it
catches an error condition.

  • Run seq 5000
  • Open search box, search for 000
  • Clear screen/history
  • Search up/down

Actual result: Crash
Expected result: Search should begin from last/first visible line

Reviewers: Konsole, hindenburg

Reviewed By: Konsole, hindenburg

Subscribers: hindenburg, konsole-devel

Tags: Konsole

Differential Revision: https://phabricator.kde.org/D14106

Details

Committed
hindenburgJul 14 2018, 5:11 PM
Reviewer
Konsole
Differential Revision
D14106: Move search line upper bound check to less generic function
Parents
R319:7aaf7eddfcf0: add a sample emoji test file
Branches
Unknown
Tags
Unknown