URL:
<http://gna.org/patch/?4326>
Summary: Allocate array on heap rather than stack in
genlist_sort()
Project: Freeciv
Submitted by: jtn
Submitted on: Sat Dec 7 11:55:34 2013
Category: general
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: jtn
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Planned Release: 2.4.2,2.5.0,2.6.0
_______________________________________________________
Details:
genlist_sort() allocates an array of pointers the size of the list to be
sorted on the stack. For long lists on platforms with small stacks, this could
blow the stack (I suspect this is what has happened in bug #20940, with the
agent callback list).
It's safer to allocate it on the heap. The runtime hit should hopefully be
negligible -- I hope no-one's calling a sort function in a tight loop.
A quick survey of other places genlist_sort() is used, looking for where this
might have caused trouble:
* HELP_NATIONS (number of nations)
* cmdarg_list_sort
* unit lists (but only units-supported-by-a-city, units-on-tiles, autoattack
candidates, most of which should be small)
* lists of server settings
None of those seem likely to trigger a stack overflow.
_______________________________________________________
Reply to this item at:
<http://gna.org/patch/?4326>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev