Skip to content

Commit

Permalink
Validate Object pointers on binder method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
KoBeWi committed Jan 2, 2024
1 parent 07b8860 commit 66f698b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/variant/binder_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ struct PtrToArg<char32_t> {
template <typename T>
struct VariantObjectClassChecker {
static _FORCE_INLINE_ bool check(const Variant &p_variant) {
#ifdef DEBUG_ENABLED
bool freed;
p_variant.get_validated_object_with_check(freed);
if (freed) {
return false;
}
#endif

using TStripped = std::remove_pointer_t<T>;
if constexpr (std::is_base_of<Object, TStripped>::value) {
Object *obj = p_variant;
Expand Down Expand Up @@ -257,6 +265,7 @@ struct VariantCasterAndValidate {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = p_arg_idx;
r_error.expected = argtype;
return VariantCaster<T>::cast(Variant());
}

return VariantCaster<T>::cast(*p_args[p_arg_idx]);
Expand Down

0 comments on commit 66f698b

Please sign in to comment.