From a0b7220d234bcc4247cfd660a32adf035b1973c9 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Mon, 25 Nov 2024 22:27:40 +0100 Subject: [PATCH] script: don't try to display the old line if it's NULL This fixes a crash which would happen if you scrolled the script buffer and then did a search which got fewer search results than the index of the selected line before the search. E.g. press page down to go to the second page and then search for `test`. --- src/plugins/script/script-buffer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/script/script-buffer.c b/src/plugins/script/script-buffer.c index bd24af0b6..7a893e577 100644 --- a/src/plugins/script/script-buffer.c +++ b/src/plugins/script/script-buffer.c @@ -818,14 +818,17 @@ void script_buffer_set_current_line (int line) { int old_line; + struct t_script_repo *old_script; if ((line >= 0) && (line < script_repo_count_displayed)) { old_line = script_buffer_selected_line; script_buffer_selected_line = line; - script_buffer_display_line_script (old_line, - script_repo_search_displayed_by_number (old_line)); + old_script = script_repo_search_displayed_by_number (old_line); + if (old_script) + script_buffer_display_line_script (old_line, old_script); + script_buffer_display_line_script (script_buffer_selected_line, script_repo_search_displayed_by_number (script_buffer_selected_line)); }