<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39717 >

On 19/09/2007, Marko Lindqvist  wrote:
>
>  Sometimes when real government is not chosen,
> pplayer->target_government is government_when_anarchy, sometimes NULL.
>  Most of the checks are against government_when_anarchy, so NULL is
> handled as real government, leading to segfault later.

 This at least fixes crash. I'll commit this to S2_1, S2_2 and trunk.


 - ML

diff -Nurd -X.diff_ignore freeciv/server/plrhand.c freeciv/server/plrhand.c
--- freeciv/server/plrhand.c	2007-07-04 14:04:17.000000000 +0300
+++ freeciv/server/plrhand.c	2007-09-23 19:18:45.000000000 +0300
@@ -239,12 +239,16 @@
 {
   struct government *government = pplayer->target_government;
 
-  if (pplayer->target_government == game.government_when_anarchy) {
-    assert(0);
+  if (pplayer->target_government == game.government_when_anarchy
+      || pplayer->target_government == NULL) {
+    /* More descriptive assert than just assert(FALSE) */
+    assert(pplayer->target_government != game.government_when_anarchy
+           && pplayer->target_government != NULL);
     return;
   }
   if (pplayer->revolution_finishes > game.info.turn) {
-    assert(0);
+    /* More descriptive assert than just assert(FALSE) */
+    assert(pplayer->revolution_finishes <= game.info.turn);
     return;
   }
 
@@ -1539,6 +1543,7 @@
   
   /* change the original player */
   if (government_of_player(pplayer) != game.government_when_anarchy) {
+    pplayer->target_government = pplayer->government;
     pplayer->government = game.government_when_anarchy;
     pplayer->revolution_finishes = game.info.turn + 1;
   }
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to