#47982: common/unit.c:2475:13: runtime error: index -1 out of bounds for type 'const struct unit_list_link *5' Open Date: 2023-05-05 10:02 Last Update: 2023-05-05 15:45 URL for this Ticket: https://osdn.net//projects/freeciv/ticket/47982 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=47982 --------------------------------------------------------------------- Last Changes/Comment on this Ticket: 2023-05-05 15:45 Updated by: cazfi Comment: Reply To alain_bkr I prefer my patch, which fixes the problem, instead of yours which only add an assert and let the wrong (-2) in the code. It didn't "only add an assert" (it didn't do that at all, on older branches), but turned "do {} while ()" to a "while() {}" so that there's no first iteration when there should be zero. So likely we need that fix anyway (or we rely on callers to do the right thing, like the assert on development branches dictates) Need to check with more time, but I don't really see what's the crucial difference your patch does, if it's related to '-2' and not the earlier part The '-2' is from the old value, and after your change there's '-1' from the new value. It's more readable than "var-- - 2" --------------------------------------------------------------------- Ticket Status: Reporter: alain_bkr Owner: (None) Type: Patches Status: Open Priority: 5 - Medium MileStone: 3.1.0-beta2 Component: Server Severity: 5 - Medium Resolution: None --------------------------------------------------------------------- Ticket details: About 50% of test games i have : ../../common/unit.c:2483:13: runtime error: index -1 out of bounds for type 'const struct unit_list_link *[5]' Looking at the code it is a list traversal, with obvious off-by-one error. Attached patch fixes it, and clarify the code. -- 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/47982 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=47982