URL:
  <http://gna.org/bugs/?20110>

                 Summary: Lack of "legend" in nations/nation.ruleset leads to
server segfault
                 Project: Freeciv
            Submitted by: rcbrgs
            Submitted on: Thu 30 Aug 2012 12:56:55 AM GMT
                Category: rulesets
                Severity: 3 - Normal
                Priority: 5 - Normal
                  Status: None
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
                 Release: 
         Discussion Lock: Any
        Operating System: Any
         Planned Release: 

    _______________________________________________________

Details:

If a nation/nation.ruleset lacks a legend specification, the server crashes
when the ruleset is loaded, without warnings, and running the server with -d 3
also does not give a clue about this.

I believe the problem is in common/nation.c, function nation_free, that has
the following line:

  free(pnation->legend);

since pnation->legend is undefined, this line attempts to free an unallocated
pointer, leading to a segmentation fault. I have verified this by commenting
this line and loading a ruleset with a nation missing its legend, and there is
no segfault in this case.

A quick fix would check if pnation->legend is NULL before freeing it, but I
think it is not unreasonable to think that future coders might assume
pnation->legend is initialized, somewhere else. So a possible permanent
solution is to assign an empty string to pnation->legend if none is specified
in the nation.ruleset.




    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?20110>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to