From 6539944e7ec2de9b1bbce6fb698cef6a64ea70fd Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 17 Jul 2023 03:54:18 +0300 Subject: [PATCH 19/19] goto.c: Fix clang analyzer warnings about NULL 'path' dereference See osdn #48406 Signed-off-by: Marko Lindqvist --- client/goto.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/client/goto.c b/client/goto.c index fc8cc6d0d7..c2202b2301 100644 --- a/client/goto.c +++ b/client/goto.c @@ -1617,9 +1617,11 @@ void send_connect_route(enum unit_activity activity, memset(&p, 0, sizeof(p)); - for (i = 0; i < goto_map->num_parts; i++) { + i = 0; + do { path = pf_path_concat(path, goto_map->parts[i].path); - } + i++; + } while (i < goto_map->num_parts); p.unit_id = punit->id; p.src_tile = tile_index(unit_tile(punit)); @@ -1739,8 +1741,9 @@ static bool order_demands_direction(enum unit_orders order, action_id act_id) /************************************************************************** Send the current goto route (i.e., the one generated via - HOVER_STATE) to the server. The route might involve more than one - part if waypoints were used. FIXME: danger paths are not supported. + HOVER_STATE) to the server. The route might involve more than one + part, if waypoints were used. + FIXME: danger paths are not supported. **************************************************************************/ void send_goto_route(void) { @@ -1756,9 +1759,11 @@ void send_goto_route(void) continue; } - for (i = 0; i < goto_map->num_parts; i++) { + i = 0; + do { path = pf_path_concat(path, goto_map->parts[i].path); - } + i++; + } while (i < goto_map->num_parts); clear_unit_orders(punit); -- 2.40.1