From 76a3fe914d869b2bf9e62d2e1eaf624f5b9967a0 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 | 2 +- client/gui-sdl3/helpdlg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index 9e68624bb9..c2db7e5527 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -2078,7 +2078,7 @@ 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--) { advance_label = advance_label->prev; } advance_label = advance_label->next; diff --git a/client/gui-sdl3/helpdlg.c b/client/gui-sdl3/helpdlg.c index 969742843a..5fa7b52815 100644 --- a/client/gui-sdl3/helpdlg.c +++ b/client/gui-sdl3/helpdlg.c @@ -2076,7 +2076,7 @@ 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--) { advance_label = advance_label->prev; } advance_label = advance_label->next; -- 2.43.0