Skip to content

Commit

Permalink
Merge pull request #76548 from komugi1211s/tilemap-ctrl-shift-edit-cr…
Browse files Browse the repository at this point in the history
…ash-fix

Fix crashes due to stack overflow when painting a large area in tile map
  • Loading branch information
akien-mga committed Jun 18, 2023
2 parents 829b865 + 09fa220 commit fc42065
Showing 1 changed file with 9 additions and 3 deletions.
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

0 comments on commit fc42065

Please sign in to comment.