(svn r23870) -Fix [FS#5004]: scripts with a bad comparator could lock up OpenTTD
This commit is contained in:
		
							
								
								
									
										4
									
								
								src/3rdparty/squirrel/squirrel/sqbaselib.cpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								src/3rdparty/squirrel/squirrel/sqbaselib.cpp
									
									
									
									
										vendored
									
									
								
							| @@ -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; | ||||
| 		} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 rubidium
					rubidium