Skip to content

Commit

Permalink
Fix wrong arguments in callv with const Array
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolkaloid committed Jun 26, 2024
1 parent ba3bb44 commit e64f92a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/variant/callable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,18 @@ void Callable::callp(const Variant **p_arguments, int p_argcount, Variant &r_ret
Variant Callable::callv(const Array &p_arguments) const {
int argcount = p_arguments.size();
const Variant **argptrs = nullptr;

if (argcount) {
argptrs = (const Variant **)alloca(sizeof(Variant *) * argcount);

// Use a duplicate if the array is readonly, otherwise the addess of p_arguments->read_only will be copied
const Array &arguments_source = p_arguments.is_read_only() ? p_arguments.duplicate() : p_arguments;

for (int i = 0; i < argcount; i++) {
argptrs[i] = &p_arguments[i];
argptrs[i] = &arguments_source[i];
}
}

CallError ce;
Variant ret;
callp(argptrs, argcount, ret, ce);
Expand Down

0 comments on commit e64f92a

Please sign in to comment.