Skip to content

Commit e9942db

Browse files
authored
Merge pull request #1044 from zhehangd/fix_obj_ptr_crash
Fix crash using Object* as parameter
2 parents 9d1c396 + 093f067 commit e9942db

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

include/godot_cpp/core/method_ptrcall.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ MAKE_PTRARG_BY_REFERENCE(Variant);
168168
template <class T>
169169
struct PtrToArg<T *> {
170170
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
171-
return reinterpret_cast<T *>(godot::internal::gde_interface->object_get_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr)), godot::internal::token, &T::___binding_callbacks));
171+
return reinterpret_cast<T *>(godot::internal::gde_interface->object_get_instance_binding(
172+
reinterpret_cast<GDExtensionObjectPtr>(const_cast<void *>(p_ptr)),
173+
godot::internal::token, &T::___binding_callbacks));
172174
}
173175
typedef Object *EncodeT;
174176
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
@@ -179,7 +181,9 @@ struct PtrToArg<T *> {
179181
template <class T>
180182
struct PtrToArg<const T *> {
181183
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
182-
return reinterpret_cast<const T *>(godot::internal::gde_interface->object_get_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr)), godot::internal::token, &T::___binding_callbacks));
184+
return reinterpret_cast<const T *>(godot::internal::gde_interface->object_get_instance_binding(
185+
reinterpret_cast<GDExtensionObjectPtr>(const_cast<void *>(p_ptr)),
186+
godot::internal::token, &T::___binding_callbacks));
183187
}
184188
typedef const Object *EncodeT;
185189
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {

0 commit comments

Comments
 (0)