From 71fafd80411261c2c0b0da4637308867a28430cb Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 20 Mar 2023 20:10:38 +0200 Subject: [PATCH 31/31] 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 9af977ad90..18531efdc3 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -1116,7 +1116,7 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, struct widget *pwidget; struct widget *last, *budynki; struct widget *dock = store->dock; - 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 *surf; @@ -1307,18 +1307,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 - store->sub_targets[j]->id; + while (i < 6 && store->targets[i]) { store->targets[i]->size.x = pwindow->size.x + start_x; store->targets[i]->size.y = start_y; if (store->sub_targets[j]) { - t0 = MAX_ID - store->targets[i]->id; - t1 = MAX_ID - store->sub_targets[j]->id; + int t0 = MAX_ID - store->targets[i]->id; + int t1 = MAX_ID - store->sub_targets[j]->id; + if (advance_required(t0, AR_ONE) == t1 || advance_required(t0, AR_TWO) == t1) { store->sub_targets[j]->size.x = pwindow->size.x + start_x + max_width + 60; -- 2.39.2