From 45b4304f10b12f49ca58bb9627bf2e3840ed5d9d Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Wed, 22 Sep 2021 13:38:21 +0800 Subject: [PATCH] Fix crash in Tween.follow_property Check `p_object` for null before using it. --- scene/animation/tween.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 7cc6a27e383b..a130f5b18529 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -1554,6 +1554,10 @@ bool Tween::follow_property(Object *p_object, NodePath p_property, Variant p_ini return true; } + // Confirm the source and target objects are valid + ERR_FAIL_NULL_V(p_object, false); + ERR_FAIL_NULL_V(p_target, false); + // Get the two properties from their paths p_property = p_property.get_as_property_path(); p_target_property = p_target_property.get_as_property_path(); @@ -1569,10 +1573,6 @@ bool Tween::follow_property(Object *p_object, NodePath p_property, Variant p_ini p_initial_val = p_initial_val.operator real_t(); } - // Confirm the source and target objects are valid - ERR_FAIL_COND_V(p_object == nullptr, false); - ERR_FAIL_COND_V(p_target == nullptr, false); - // No negative durations ERR_FAIL_COND_V(p_duration < 0, false);