From 479cc1d32dec2b53c1ddaa0faf1dfcdf545de180 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 20 Mar 2023 20:04:30 +0200 Subject: [PATCH 16/16] sdl2: Fix tech help NULL dereference See osdn #47615 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/helpdlg.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index d37d947bfd..231fe7ae2c 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -1108,7 +1108,7 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, struct widget *pWidget; struct widget *pLast, *pBudynki; struct widget *pDock = pStore->pDock; - int i, targets_count,sub_targets_count, max_width = 0; + int i, targets_count, sub_targets_count, max_width = 0; int start_x, start_y, imp_count, unit_count, flags_count, gov_count; char buffer[bufsz]; SDL_Surface *pSurf; @@ -1300,18 +1300,18 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, start_y = pWidget->size.y + pWidget->size.h + adj_size(30); if (targets_count) { - int j, t0, t1; + int j = 0; i = 0; - j = 0; - t1 = MAX_ID - pStore->pSub_Targets[j]->ID; + while (i < 6 && pStore->pTargets[i]) { pStore->pTargets[i]->size.x = pWindow->size.x + start_x; pStore->pTargets[i]->size.y = start_y; if (pStore->pSub_Targets[j]) { - t0 = MAX_ID - pStore->pTargets[i]->ID; - t1 = MAX_ID - pStore->pSub_Targets[j]->ID; + int t0 = MAX_ID - pStore->pTargets[i]->ID; + int t1 = MAX_ID - pStore->pSub_Targets[j]->ID; + if (advance_required(t0, AR_ONE) == t1 || advance_required(t0, AR_TWO) == t1) { pStore->pSub_Targets[j]->size.x = pWindow->size.x + start_x + max_width + 60; -- 2.39.2