From 43675d842b437035bc7055640df03eeb1bca62ad Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 1 Jun 2023 16:26:20 +0300 Subject: [PATCH 20/20] Client: Do not assert against bad behavior from pre-obsinv server Servers without "obsinv" capability are known to be buggy. Handle such servers best we can, assert only when connected to a newer server. See osdn #48046 Signed-off-by: Marko Lindqvist --- client/packhand.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/client/packhand.c b/client/packhand.c index 30b915514f..b4baa7709f 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -2187,12 +2187,26 @@ void handle_unit_short_info(const struct packet_unit_short_info *packet) /* Append a unit struct to the proper list. */ punit = unpackage_short_unit(packet); if (packet->packet_use == UNIT_INFO_CITY_SUPPORTED) { - fc_assert(pcity->client.collecting_info_units_supported != NULL); - unit_list_append(pcity->client.collecting_info_units_supported, punit); + if (pcity->client.collecting_info_units_supported != NULL) { + unit_list_append(pcity->client.collecting_info_units_supported, punit); + } else { + /* pcity->client.collecting_info_units_supported should not be NULL, + * but older servers never started the sequence for observers. */ + fc_assert_msg(!(has_capability("obsinv", client.conn.capability) + && client_is_observer()), + "Supported units list NULL"); + } } else { fc_assert(packet->packet_use == UNIT_INFO_CITY_PRESENT); - fc_assert(pcity->client.collecting_info_units_present != NULL); - unit_list_append(pcity->client.collecting_info_units_present, punit); + if (pcity->client.collecting_info_units_present != NULL) { + unit_list_append(pcity->client.collecting_info_units_present, punit); + } else { + /* pcity->client.collecting_info_units_present should not be NULL, + * but older servers never started the sequence for observers. */ + fc_assert_msg(!(has_capability("obsinv", client.conn.capability) + && client_is_observer()), + "Present units list NULL"); + } } /* Done with special case. */ -- 2.39.2