[Freeciv-tickets] [freeciv] #47982: common/unit.c:2475:13: runtime error: index -1 out of bounds for type 'const struct unit_list_link *5'

Back to archive index
OSDN Ticket System norep****@osdn*****
Sun May 7 00:56:14 JST 2023


#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-06 18:56

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-06 18:56 Updated by: cazfi

Comment:

Reply To alain_bkr
  * before my patch the value could be -1  ( when var-- =1 , so we have 1 - 2 = -1 which is not valid)
I had just missed the line number 2483 in ticket details (different from line number on subject line). So yes, on that line there is access of index -1, just before the loop terminates as var-- makes var 0.

---------------------------------------------------------------------
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



More information about the Freeciv-tickets mailing list
Back to archive index