From 92f4390c410edcd49c9e36c945649d6fd23e0c94 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 17 Jul 2023 03:51:12 +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 4255df8f5d..7c334d7749 100644 --- a/client/goto.c +++ b/client/goto.c @@ -1730,9 +1730,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)); @@ -1862,8 +1864,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) { @@ -1879,9 +1882,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