From 8ef39f1577104ded40588ec8c13994c4c947df45 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Fri, 22 Mar 2024 02:58:34 +0200
Subject: [PATCH 18/18] Avoid announce_trade_route_removal() call with a NULL
 city

See RM #335

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 server/citytools.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/server/citytools.c b/server/citytools.c
index bf7ba1f7fd..f937bc454d 100644
--- a/server/citytools.c
+++ b/server/citytools.c
@@ -102,7 +102,8 @@ static bool send_city_suppressed = FALSE;
 static bool city_workers_queue_remove(struct city *pcity);
 
 static void announce_trade_route_removal(struct city *pc1, struct city *pc2,
-                                         bool source_gone);
+                                         bool source_gone)
+  fc__attribute((nonnull (1, 2)));
 
 /************************************************************************//**
   Freeze the workers (citizens on tiles) for the city. They will not be
@@ -2850,13 +2851,13 @@ struct trade_route *remove_trade_route(struct city *pc1, struct trade_route *pro
     if (back_route != NULL) {
       trade_route_list_remove(pc2->routes, back_route);
     }
-  }
 
-  if (announce) {
-    announce_trade_route_removal(pc1, pc2, source_gone);
+    if (announce) {
+      announce_trade_route_removal(pc1, pc2, source_gone);
 
-    city_refresh(pc2);
-    send_city_info(city_owner(pc2), pc2);
+      city_refresh(pc2);
+      send_city_info(city_owner(pc2), pc2);
+    }
   }
 
   return back_route;
-- 
2.43.0

