summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-01-29 14:27:21 +0000
committerrubidium <rubidium@openttd.org>2012-01-29 14:27:21 +0000
commitcd735fb613b879c52f17727105a351f34b538387 (patch)
tree84876ae36cc9bedb108c7ada3adbd4b41ad5b406 /src
parent8cd3229727a8ca7cccae50d4976d5c1035705d63 (diff)
downloadopenttd-cd735fb613b879c52f17727105a351f34b538387.tar.xz
(svn r23870) -Fix [FS#5004]: scripts with a bad comparator could lock up OpenTTD
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/squirrel/squirrel/sqbaselib.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/3rdparty/squirrel/squirrel/sqbaselib.cpp b/src/3rdparty/squirrel/squirrel/sqbaselib.cpp
index 8d2126950..486b888b5 100644
--- a/src/3rdparty/squirrel/squirrel/sqbaselib.cpp
+++ b/src/3rdparty/squirrel/squirrel/sqbaselib.cpp
@@ -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;
}