mirror of https://github.com/OpenTTD/OpenTTD
(svn r23870) -Fix [FS#5004]: scripts with a bad comparator could lock up OpenTTD
parent
8cd3229727
commit
cd735fb613
|
@ -538,6 +538,10 @@ bool _hsort_sift_down(HSQUIRRELVM v,SQArray *arr, SQInteger root, SQInteger bott
|
|||
if(!_sort_compare(v,arr->_values[root],arr->_values[maxChild],func,ret))
|
||||
return false;
|
||||
if (ret < 0) {
|
||||
if (root == maxChild) {
|
||||
v->Raise_Error(_SC("inconsistent compare function"));
|
||||
return false; // We'd be swapping ourselve. The compare function is incorrect
|
||||
}
|
||||
_Swap(arr->_values[root],arr->_values[maxChild]);
|
||||
root = maxChild;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue