From a94a16a511e7f35bddfa3013d2f1e00809087876 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Fri, 2 Oct 2026 21:39:42 +0300
Subject: [PATCH 78/78] Fix client crash on government_name_for_player()

Reported by Michael Ortmann

See RM #2238

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/plrdlg_common.c | 12 ++----------
 common/government.c    | 12 +++++++++++-
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/client/plrdlg_common.c b/client/plrdlg_common.c
index 2beedb1c5e..ed46d79921 100644
--- a/client/plrdlg_common.c
+++ b/client/plrdlg_common.c
@@ -319,17 +319,9 @@ static int cmp_score(const struct player *player1,
 static const char *col_government(const struct player *them)
 {
   static char buf[100];
-  const struct player *me = client_player();
 
-  /*  'contact' gives the knowledge of other's government */
-  if (me == them
-      || client_is_global_observer()
-      || team_has_embassy(me->team, them)
-      || player_diplstate_get(me, them)->contact_turns_left > 0 ) {
-    fc_snprintf(buf, sizeof(buf),"%s", government_name_for_player(them));
-  } else {
-    fc_snprintf(buf, sizeof(buf),"?");
-  }
+  /* This gives sensible result even when the government is not known */
+  fc_snprintf(buf, sizeof(buf), "%s", government_name_for_player(them));
 
   return buf;
 }
diff --git a/common/government.c b/common/government.c
index ce96a4c246..203508d990 100644
--- a/common/government.c
+++ b/common/government.c
@@ -149,11 +149,21 @@ const char *government_name_translation(const struct government *pgovern)
 **************************************************************************/
 const char *government_name_for_player(const struct player *pplayer)
 {
+  const struct government *pgov;
+
   if (!pplayer->is_alive) {
     return "-";
   }
 
-  return government_name_translation(government_of_player(pplayer));
+  pgov = government_of_player(pplayer);
+
+  if (!pgov) {
+    /* Can happen on client side when we have
+     * no contact to the player. */
+    return "?";
+  }
+
+  return government_name_translation(pgov);
 }
 
 /**********************************************************************//**
-- 
2.53.0

