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

Back to archive index
OSDN Ticket System norep****@osdn*****
Mon Oct 17 21:35:19 JST 2022


#45893: city_create_unit() segfaults when punit is null

  Open Date: 2022-10-17 14:58
Last Update: 2022-10-17 15:35

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:
2022-10-17 15:35 Updated by: cazfi

Comment:

Reply To (Anonymous)
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.
Those cases with multiple build slots producing NULL units seem like result of FCW specific bugs #45894 and #45895

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

      Reporter: (Anonymous)
         Owner: (None)
          Type: Bugs
        Status: Open
      Priority: 5 - Medium
     MileStone: (None)
     Component: (None)
      Severity: 5 - Medium
    Resolution: None
---------------------------------------------------------------------

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
Back to archive index