Skip to content

Commit de25cc7

Browse files
committed
Fix UB (check accidentally only done in strict, not balanced)
1 parent b61c4f4 commit de25cc7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

godot-core/src/obj/base.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ impl<T: GodotClass> Base<T> {
9696
/// `base` must be alive at the time of invocation, i.e. user `init()` (which could technically destroy it) must not have run yet.
9797
/// If `base` is destroyed while the returned `Base<T>` is in use, that constitutes a logic error, not a safety issue.
9898
pub(crate) unsafe fn from_base(base: &Base<T>) -> Base<T> {
99-
#[cfg(safeguards_strict)]
100-
assert!(base.obj.is_instance_valid());
99+
#[cfg(safeguards_balanced)]
100+
assert!(
101+
base.obj.is_instance_valid(),
102+
"Cannot construct Base; was object freed during initialization?"
103+
);
101104

102105
let obj = Gd::from_obj_sys_weak(base.obj.obj_sys());
103106

0 commit comments

Comments
 (0)