Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts can lock up OpenTTD with a bad comparator for sorting #5004

Closed
DorpsGek opened this issue Jan 22, 2012 · 3 comments
Closed

Scripts can lock up OpenTTD with a bad comparator for sorting #5004

DorpsGek opened this issue Jan 22, 2012 · 3 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

frosch opened the ticket and wrote:

ChooChoo uses this comparator:

function CompareRouteValue(a, b) {
return a.payback > b.payback ? 1 : -1;
}

It causes an infinite loop in _hsort_sift_down when root == root2 == bottom == maxChild since comparing an element with itself returned -1.

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5004
@DorpsGek
Copy link
Member Author

Rubidium wrote:

Simplified version that triggers this in Squirrel:

function Cmp(a, b) { return a > b ? 1 : -1 }
local arr = [ 1, 0 ];
arr.sort(Cmp);


This comment was imported from FlySpray: https://bugs.openttd.org/task/5004#comment10808

@DorpsGek
Copy link
Member Author

Rubidium wrote:

Possible fix

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5004#comment10809

@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Fixed

In r23870


This comment was imported from FlySpray: https://bugs.openttd.org/task/5004

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug labels Apr 7, 2018
This was referenced Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant