From 44d38d7f1868df340f063368f83089accc541497 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 7 Feb 2024 21:46:20 +0200 Subject: [PATCH 19/19] sdl/2: Fix NULL dereference in popup_tech_info() See osdn #48687 Signed-off-by: Marko Lindqvist --- client/gui-sdl/helpdlg.c | 5 ++--- client/gui-sdl2/helpdlg.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/client/gui-sdl/helpdlg.c b/client/gui-sdl/helpdlg.c index 2fe9748789..f953fb9f6d 100644 --- a/client/gui-sdl/helpdlg.c +++ b/client/gui-sdl/helpdlg.c @@ -2040,7 +2040,7 @@ void popup_tech_info(Tech_type_id tech) } if (pStore->show_full_tree) { - /* all entries are visible without scrolling */ + /* All entries are visible without scrolling */ hide_group(pHelpDlg->pBeginActiveWidgetList, pHelpDlg->pEndActiveWidgetList); hide_scrollbar(pHelpDlg->pScroll); @@ -2048,10 +2048,9 @@ void popup_tech_info(Tech_type_id tech) int count = pHelpDlg->pScroll->active; pAdvanceLabel = pHelpDlg->pActiveWidgetList; - while (pAdvanceLabel && count--) { + while (pAdvanceLabel->prev != NULL && --count > 0) { pAdvanceLabel = pAdvanceLabel->prev; } - pAdvanceLabel = pAdvanceLabel->next; show_group(pAdvanceLabel, pHelpDlg->pActiveWidgetList); show_scrollbar(pHelpDlg->pScroll); } diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index 9ba812dbb6..d38960e6d2 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -2071,7 +2071,7 @@ void popup_tech_info(Tech_type_id tech) } if (pStore->show_full_tree) { - /* all entries are visible without scrolling */ + /* All entries are visible without scrolling */ hide_group(pHelpDlg->pBeginActiveWidgetList, pHelpDlg->pEndActiveWidgetList); hide_scrollbar(pHelpDlg->pScroll); @@ -2079,10 +2079,9 @@ void popup_tech_info(Tech_type_id tech) int count = pHelpDlg->pScroll->active; pAdvanceLabel = pHelpDlg->pActiveWidgetList; - while (pAdvanceLabel && count--) { + while (pAdvanceLabel->prev != NULL && --count > 0) { pAdvanceLabel = pAdvanceLabel->prev; } - pAdvanceLabel = pAdvanceLabel->next; show_group(pAdvanceLabel, pHelpDlg->pActiveWidgetList); show_scrollbar(pHelpDlg->pScroll); } -- 2.43.0