From 0caae00b77c7b02882521e2a1253c68413ee57f5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 15 Oct 2023 21:54:24 +0300 Subject: [PATCH 31/31] city_from_wonder(): Fix illegal array subscript warning See osdn #48849 Signed-off-by: Marko Lindqvist --- common/improvement.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/improvement.c b/common/improvement.c index a8e04e4ff5..39eda11b8e 100644 --- a/common/improvement.c +++ b/common/improvement.c @@ -890,7 +890,14 @@ bool wonder_is_built(const struct player *pplayer, struct city *city_from_wonder(const struct player *pplayer, const struct impr_type *pimprove) { - int city_id = pplayer->wonders[improvement_index(pimprove)]; + int idx = improvement_index(pimprove); + int city_id; + + if (idx < 0) { + return NULL; + } + + city_id = pplayer->wonders[idx]; fc_assert_ret_val(NULL != pplayer, NULL); fc_assert_ret_val(is_wonder(pimprove), NULL); -- 2.42.0