From 1c51a5cfc6b32174670dcbedd3558dccc3e240e5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 7 Feb 2024 21:31:54 +0200 Subject: [PATCH 38/38] sdl2/3: Fix NULL dereference in popup_tech_info() See osdn #48687 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/helpdlg.c | 3 +-- client/gui-sdl3/helpdlg.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index 9e68624bb9..8ee0b5a3a5 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -2078,10 +2078,9 @@ void popup_tech_info(Tech_type_id tech) int count = help_dlg->scroll->active; advance_label = help_dlg->active_widget_list; - while (advance_label && count--) { + while (advance_label->prev != NULL && --count > 0) { advance_label = advance_label->prev; } - advance_label = advance_label->next; show_group(advance_label, help_dlg->active_widget_list); show_scrollbar(help_dlg->scroll); } diff --git a/client/gui-sdl3/helpdlg.c b/client/gui-sdl3/helpdlg.c index 969742843a..c16e877875 100644 --- a/client/gui-sdl3/helpdlg.c +++ b/client/gui-sdl3/helpdlg.c @@ -2076,10 +2076,9 @@ void popup_tech_info(Tech_type_id tech) int count = help_dlg->scroll->active; advance_label = help_dlg->active_widget_list; - while (advance_label && count--) { + while (advance_label->prev != NULL && --count > 0) { advance_label = advance_label->prev; } - advance_label = advance_label->next; show_group(advance_label, help_dlg->active_widget_list); show_scrollbar(help_dlg->scroll); } -- 2.43.0