Convert Object::cast_to() to the static version
Currently we rely on some undefined behavior when Object->cast_to() gets called with a Null pointer. This used to work fine with GCC < 6 but newer versions of GCC remove all codepaths in which the this pointer is Null. However, the non-static cast_to() was supposed to be null safe. This patch makes cast_to() Null safe and removes the now redundant Null checks where they existed. It is explained in this article: https://www.viva64.com/en/b/0226/
This commit is contained in:
@ -29,7 +29,7 @@ public:
|
||||
|
||||
virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error) {
|
||||
|
||||
T *instance=p_object->cast_to<T>();
|
||||
T *instance=Object::cast_to<T>(p_object);
|
||||
r_error.error=Variant::CallError::CALL_OK;
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
|
||||
@ -57,7 +57,7 @@ public:
|
||||
#ifdef PTRCALL_ENABLED
|
||||
virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) {
|
||||
|
||||
T *instance=p_object->cast_to<T>();
|
||||
T *instance=Object::cast_to<T>(p_object);
|
||||
$ifret PtrToArg<R>::encode( $ (instance->*method)($arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret)$ ;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user