Hi,

Attached to this message is a patch to fix the issue reported in PR#39330. Basically, the problem seems to be that cities can see unknown terrain, and this is considered acceptable and normal. But, in at least one place in the code that possibility is overlooked. In a player's view of a tile, the terrain ptr may be NULL (indicating it is unknown). Attempts to reference a member, such as 'type', of such a NULL ptr obviously results in a segfault.

Eric
Index: server/maphand.c
===================================================================
--- server/maphand.c    (revision 12911)
+++ server/maphand.c    (working copy)
@@ -476,9 +476,9 @@
       struct player_tile *plrtile = map_get_player_tile(ptile, pplayer);
 
       info.known = TILE_KNOWN_FOGGED;
-      info.type = plrtile->terrain->index;
+      info.type = plrtile->terrain ? plrtile->terrain->index : -1;
       for (spe = 0; spe < S_LAST; spe++) {
-       info.special[spe] = BV_ISSET(plrtile->special, spe);
+        info.special[spe] = BV_ISSET(plrtile->special, spe);
       }
       info.resource = plrtile->resource ? plrtile->resource->index : -1;
       info.continent = ptile->continent;
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to