Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes due to stack overflow when painting a large area in tile map #76548

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions core/object/undo_redo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ void UndoRedo::commit_action(bool p_execute) {
}

void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
const int PREALLOCATE_ARGS_COUNT = 16;

LocalVector<const Variant *> args;
args.reserve(PREALLOCATE_ARGS_COUNT);

for (; E; E = E->next()) {
Operation &op = E->get();

Expand Down Expand Up @@ -347,12 +352,13 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
if (binds.is_empty()) {
method_callback(method_callback_ud, obj, op.name, nullptr, 0);
} else {
const Variant **args = (const Variant **)alloca(sizeof(const Variant **) * binds.size());
args.clear();

for (int i = 0; i < binds.size(); i++) {
args[i] = (const Variant *)&binds[i];
args.push_back(&binds[i]);
}

method_callback(method_callback_ud, obj, op.name, args, binds.size());
method_callback(method_callback_ud, obj, op.name, args.ptr(), binds.size());
}
}
} break;
Expand Down