Skip to content

Commit 970b40b

Browse files
committed
Fix UB with StringName accidentally dropped in unwrap()
1 parent 9ca6907 commit 970b40b

File tree

1 file changed

+2
-1
lines changed
  • godot-core/src/builtin/collections

1 file changed

+2
-1
lines changed

godot-core/src/builtin/collections/array.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,8 @@ impl<T: ArrayElement> Array<T> {
813813
class_name.string_sys()
814814
} else {
815815
empty_string_name = Some(StringName::default());
816-
empty_string_name.unwrap().string_sys()
816+
// as_ref() crucial here -- otherwise the StringName is dropped.
817+
empty_string_name.as_ref().unwrap().string_sys()
817818
};
818819

819820
// SAFETY: The array is a newly created empty untyped array.

0 commit comments

Comments
 (0)