Check if _direct_state_changed() argument is valid
- Modified classes: RigidBody, PhysicalBone, VehicleBody, RigidBody2D, KinematicBody2D
- The input argument is untrusted even in release mode
(cherry picked from commit e075b6b411
)
This commit is contained in:
parent
7a6a150bc2
commit
3ab33d3ce9
|
@ -440,12 +440,8 @@ bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia,
|
|||
}
|
||||
|
||||
void RigidBody2D::_direct_state_changed(Object *p_state) {
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
state = Object::cast_to<Physics2DDirectBodyState>(p_state);
|
||||
#else
|
||||
state = (Physics2DDirectBodyState *)p_state; //trust it
|
||||
#endif
|
||||
ERR_FAIL_COND_MSG(!state, "Method '_direct_state_changed' must receive a valid Physics2DDirectBodyState object as argument");
|
||||
|
||||
set_block_transform_notify(true); // don't want notify (would feedback loop)
|
||||
if (mode != MODE_KINEMATIC)
|
||||
|
@ -1437,11 +1433,11 @@ bool KinematicBody2D::is_sync_to_physics_enabled() const {
|
|||
}
|
||||
|
||||
void KinematicBody2D::_direct_state_changed(Object *p_state) {
|
||||
|
||||
if (!sync_to_physics)
|
||||
return;
|
||||
|
||||
Physics2DDirectBodyState *state = Object::cast_to<Physics2DDirectBodyState>(p_state);
|
||||
ERR_FAIL_COND_MSG(!state, "Method '_direct_state_changed' must receive a valid Physics2DDirectBodyState object as argument");
|
||||
|
||||
last_valid_transform = state->get_transform();
|
||||
set_notify_local_transform(false);
|
||||
|
|
|
@ -442,12 +442,8 @@ struct _RigidBodyInOut {
|
|||
};
|
||||
|
||||
void RigidBody::_direct_state_changed(Object *p_state) {
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
state = Object::cast_to<PhysicsDirectBodyState>(p_state);
|
||||
#else
|
||||
state = (PhysicsDirectBodyState *)p_state; //trust it
|
||||
#endif
|
||||
ERR_FAIL_COND_MSG(!state, "Method '_direct_state_changed' must receive a valid PhysicsDirectBodyState object as argument");
|
||||
|
||||
set_ignore_transform_notification(true);
|
||||
set_global_transform(state->get_transform());
|
||||
|
@ -2220,13 +2216,8 @@ void PhysicalBone::_direct_state_changed(Object *p_state) {
|
|||
|
||||
/// Update bone transform
|
||||
|
||||
PhysicsDirectBodyState *state;
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
state = Object::cast_to<PhysicsDirectBodyState>(p_state);
|
||||
#else
|
||||
state = (PhysicsDirectBodyState *)p_state; //trust it
|
||||
#endif
|
||||
PhysicsDirectBodyState *state = Object::cast_to<PhysicsDirectBodyState>(p_state);
|
||||
ERR_FAIL_COND_MSG(!state, "Method '_direct_state_changed' must receive a valid PhysicsDirectBodyState object as argument");
|
||||
|
||||
Transform global_transform(state->get_transform());
|
||||
|
||||
|
|
|
@ -857,10 +857,10 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
|
|||
}
|
||||
|
||||
void VehicleBody::_direct_state_changed(Object *p_state) {
|
||||
|
||||
RigidBody::_direct_state_changed(p_state);
|
||||
|
||||
state = Object::cast_to<PhysicsDirectBodyState>(p_state);
|
||||
ERR_FAIL_COND_MSG(!state, "Method '_direct_state_changed' must receive a valid PhysicsDirectBodyState object as argument");
|
||||
|
||||
float step = state->get_step();
|
||||
|
||||
|
|
Loading…
Reference in New Issue