(svn r23870) -Fix [FS#5004]: scripts with a bad comparator could lock up OpenTTD

This commit is contained in:
rubidium 2012-01-29 14:27:21 +00:00
parent 399186526a
commit a90ad57763

View File

@ -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;
}