As pointed out by @ragnarov on issue #168, ClipIt crashes when the history shortcut is pressed and the history is already open. The crash actually happens whenever a special character such as Ctrl, Alt, Backspace or the arrow keys are pressed, since it causes the pointer match inside selected_from_input() to point to an empty char string. Then it propagates into undeline_match(), and causes a segmentation fault.
The program already performs a validity check for match inside selected_by_input() by using a conditional if (match) before calling underline_match(). However, it only catches the case when match is a null pointer.
This pull request is quite simple and consists in two commits. The first commit extends the validity check on selected_by_input() to ensure that match points to a non-empty char string, thus fixing all the related crash cases I could find while preserving the right character count for posterior key presses. The second commit removes a redundant if (match) included inside underline_match(), which is unnecessary since the function is only called after this condition is already ensured.
Hello!
As pointed out by @ragnarov on issue #168, ClipIt crashes when the history shortcut is pressed and the history is already open. The crash actually happens whenever a special character such as Ctrl, Alt, Backspace or the arrow keys are pressed, since it causes the pointer
match
insideselected_from_input()
to point to an empty char string. Then it propagates intoundeline_match()
, and causes a segmentation fault.The program already performs a validity check for
match
insideselected_by_input()
by using a conditionalif (match)
before callingunderline_match()
. However, it only catches the case whenmatch
is a null pointer.This pull request is quite simple and consists in two commits. The first commit extends the validity check on
selected_by_input()
to ensure thatmatch
points to a non-empty char string, thus fixing all the related crash cases I could find while preserving the right character count for posterior key presses. The second commit removes a redundantif (match)
included insideunderline_match()
, which is unnecessary since the function is only called after this condition is already ensured.Cheers!