Ticket #45893

city_create_unit() segfaults when punit is null

Eröffnet am: 2022-10-17 20:58 Letztes Update: 2023-06-12 03:23

Auswertung:
(Anonym)
Verantwortlicher:
Typ:
Status:
Geschlossen
Komponente:
Meilenstein:
Priorität:
5 - Mittel
Schweregrad:
5 - Mittel
Lösung:
Gefixt
Datei:
1

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.

  1. static struct unit *city_create_unit(struct city *pcity,
  2. const struct unit_type *utype)
  3. {
  4. if (!pcity || !utype) return NULL; // 17Oct2022 attempt to avoid segfault
  5. struct player *pplayer = city_owner(pcity);
  6. struct unit *punit;
  7. int saved_unit_id;
  8. city_production_unit_veteran_level(pcity, utype),
  9. pcity->id, 0);
  10. pplayer->score.units_built++;
  11. if (!punit) {
  12. notify_conn(game.est_connections, city_tile(pcity),
  13. E_WONDER_WILL_BE_BUILT, ftc_server,
  14. _("Notice: %s in %s creating illegal segfault. Report to admin immediately!"),
  15. utype_name_translation(utype),
  16. city_link(pcity));
  17. return NULL; // 17Oct2022 line below was segfault:
  18. }
  19. saved_unit_id = punit->id;

Ticket-Verlauf (3/5 Historien)

2022-10-17 20:58 Aktualisiert von: None
  • New Ticket "city_create_unit() segfaults when punit is null" created
2022-10-17 21:35 Aktualisiert von: cazfi
Kommentar

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

2023-06-09 07:36 Aktualisiert von: cazfi
  • Verantwortlicher Update from (Keine) to cazfi
  • Lösung Update from Keine to Accepted
  • Meilenstein Update from (Keine) to 3.1.0-beta3 (closed)
  • Komponente Update from (Keine) to Server
  • Typ Update from Fehler to Patches
Kommentar

Reply To cazfi

Those cases with multiple build slots producing NULL units seem like result of FCW specific bugs #45894 and #45895

Attached patch gives those parameters nonnull attribute, to make it likely that in the future such bugs get caught as soon as they get created.

2023-06-12 03:23 Aktualisiert von: cazfi
  • Status Update from Offen to Geschlossen
  • Lösung Update from Accepted to Gefixt

Bearbeiten

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Anmelden