Skip to content

Commit

Permalink
Fix crash in Tween.follow_property
Browse files Browse the repository at this point in the history
Check `p_object` for null before using it.
  • Loading branch information
timothyqiu committed Sep 22, 2021
1 parent dd0ee48 commit 45b4304
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scene/animation/tween.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);

Expand Down

0 comments on commit 45b4304

Please sign in to comment.