From 7beede64093f8d6397948a1e8f99ad0effbf9f4b 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 | 4 ++-- client/gui-sdl2/helpdlg.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/gui-sdl/helpdlg.c b/client/gui-sdl/helpdlg.c index 2fe9748789..e9fd27d1c8 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,7 +2048,7 @@ void popup_tech_info(Tech_type_id tech) int count = pHelpDlg->pScroll->active; pAdvanceLabel = pHelpDlg->pActiveWidgetList; - while (pAdvanceLabel && count--) { + while (pAdvanceLabel->prev != NULL && count--) { pAdvanceLabel = pAdvanceLabel->prev; } pAdvanceLabel = pAdvanceLabel->next; diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index 9ba812dbb6..fcd3153126 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,7 +2079,7 @@ void popup_tech_info(Tech_type_id tech) int count = pHelpDlg->pScroll->active; pAdvanceLabel = pHelpDlg->pActiveWidgetList; - while (pAdvanceLabel && count--) { + while (pAdvanceLabel->prev != NULL && count--) { pAdvanceLabel = pAdvanceLabel->prev; } pAdvanceLabel = pAdvanceLabel->next; -- 2.43.0