Change: Limit total script ops that can be consumed by a list valuate (#11670)
This commit is contained in:

committed by
GitHub

parent
502a52edd5
commit
48b6b1844a
@@ -11,7 +11,9 @@
|
||||
#include "script_list.hpp"
|
||||
#include "script_controller.hpp"
|
||||
#include "../../debug.h"
|
||||
#include "../../core/backup_type.hpp"
|
||||
#include "../../script/squirrel.hpp"
|
||||
#include <../squirrel/sqvm.h>
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
@@ -866,6 +868,14 @@ SQInteger ScriptList::Valuate(HSQUIRRELVM vm)
|
||||
bool backup_allow = ScriptObject::GetAllowDoCommand();
|
||||
ScriptObject::SetAllowDoCommand(false);
|
||||
|
||||
/* Limit the total number of ops that can be consumed by a valuate operation */
|
||||
SQInteger new_ops_error_threshold = vm->_ops_till_suspend_error_threshold;
|
||||
if (vm->_ops_till_suspend_error_threshold == INT64_MIN) {
|
||||
new_ops_error_threshold = vm->_ops_till_suspend - MAX_VALUATE_OPS;
|
||||
vm->_ops_till_suspend_error_label = "valuator function";
|
||||
}
|
||||
AutoRestoreBackup ops_error_threshold_backup(vm->_ops_till_suspend_error_threshold, new_ops_error_threshold);
|
||||
|
||||
/* Push the function to call */
|
||||
sq_push(vm, 2);
|
||||
|
||||
|
Reference in New Issue
Block a user