From efd54e591f751051ccd8ff6b545d9215102259e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C5=82awomir=20Lach?= <slawek@lach.art.pl>
Date: Sun, 26 Feb 2023 18:13:34 +0100
Subject: [PATCH] =?UTF-8?q?!OSDN:=20TICKET:=20#46499:=20S=C5=82awomir=20La?=
 =?UTF-8?q?ch=20<slawek@lach.art.pl>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Game not saving city id list, if there was no city counter.

diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c
index 1ef846627e..c503410620 100644
--- a/server/savegame/savegame3.c
+++ b/server/savegame/savegame3.c
@@ -2659,11 +2659,16 @@ static void sg_save_counters(struct savedata *saving)
   int    i, j, count;
 
   count = counters_get_city_counters_count();
-  countnames = fc_calloc(count, sizeof(*countnames));
 
   secfile_insert_int(saving->file, count,
                      "savefile.city_counters_order_size");
 
+  if (0 == count) {
+
+    return;
+  }
+
+  countnames = fc_calloc(count, sizeof(*countnames));
   for (j = 0; j < count; j++) {
     countnames[j] = counter_rule_name(counter_by_index(j, CTGT_CITY));
   }
-- 
2.39.2

