From ca63333df4f0b359f090c7cb19aaea9ae500c1f8 Mon Sep 17 00:00:00 2001
From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Date: Sat, 7 Nov 2026 17:39:20 -0800
Subject: [PATCH] common: Do not dereference a missing goods type in
 actres_possible()

The trade route branch of actres_possible() uses the goods the unit
would carry without checking that unit_current_goods() found any,
while the other partner lookups in the trade route code guard theirs.
No goods, no route.

Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
---
 common/actres.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/actres.c b/common/actres.c
index b7b4f7fcce..08b344ac73 100644
--- a/common/actres.c
+++ b/common/actres.c
@@ -933,8 +933,9 @@ enum fc_tristate actres_possible(const struct civ_map *nmap,
       if (result == ACTRES_TRADE_ROUTE) {
         struct goods_type *pgood = unit_current_goods(actor->unit, homecity);
 
-        if (!can_establish_trade_route(homecity, target->city,
-                                       pgood->replace_priority)) {
+        if (pgood == nullptr
+            || !can_establish_trade_route(homecity, target->city,
+                                          pgood->replace_priority)) {
           return TRI_NO;
         }
       }
-- 
2.55.0

