[Freeciv-tickets] [freeciv] #45893: city_create_unit() segfaults when punit is null

アーカイブの一覧に戻る
OSDN Ticket System norep****@osdn*****
Mon Jun 12 03:23:46 JST 2023


#45893: city_create_unit() segfaults when punit is null

  Open Date: 2022-10-17 14:58
Last Update: 2023-06-11 21:23

URL for this Ticket:
    https://osdn.net//projects/freeciv/ticket/45893
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=45893

---------------------------------------------------------------------

Last Changes/Comment on this Ticket:
2023-06-11 21:23 Updated by: cazfi
 * Status Update from Open to Closed
 * Resolution Update from Accepted to Fixed


---------------------------------------------------------------------
Ticket Status:

      Reporter: (Anonymous)
         Owner: cazfi
          Type: Patches
        Status: Closed
      Priority: 5 - Medium
     MileStone: 3.1.0-beta3
     Component: Server
      Severity: 5 - Medium
    Resolution: Fixed
---------------------------------------------------------------------

Ticket details:

This wasn't caught before because it's very rare. However, there may be ways to get units which are null in some situations like multiple build slots, etc. FCW server experienced it and had to fix it.
 static struct unit *city_create_unit(struct city *pcity,                                      const struct unit_type *utype) {   if (!pcity || !utype) return NULL;   // 17Oct2022 attempt to avoid segfault    struct player *pplayer = city_owner(pcity);   struct unit *punit;   int saved_unit_id;                       city_production_unit_veteran_level(pcity, utype),                       pcity->id, 0);   pplayer->score.units_built++;   if (!punit) {           notify_conn(game.est_connections, city_tile(pcity),                   E_WONDER_WILL_BE_BUILT, ftc_server,                   _("Notice: %s in %s creating illegal segfault. Report to admin immediately!"),                   utype_name_translation(utype),                    city_link(pcity));     return NULL;              // 17Oct2022 line below was segfault:   }   saved_unit_id = punit->id;

-- 
Ticket information of Freeciv project
Freeciv Project is hosted on OSDN

Project URL: https://osdn.net/projects/freeciv/
OSDN: https://osdn.net

URL for this Ticket:
    https://osdn.net/projects/freeciv/ticket/45893
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=45893



More information about the Freeciv-tickets mailing list
アーカイブの一覧に戻る