Skip to content

Commit a109e55

Browse files
committed
Fix 3 memory leaks in array and dictionary
Affected: * TypedArray::share() * Dictionary::share() * PackedArray::from(&Array) Output from Godot compiled with LeakSanitizer, prior to this commit: SUMMARY: AddressSanitizer: 864 byte(s) leaked in 10 allocation(s).
1 parent 585076e commit a109e55

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

godot-core/src/builtin/array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ impl<T: VariantMetadata> fmt::Debug for TypedArray<T> {
591591
impl<T: VariantMetadata> Share for TypedArray<T> {
592592
fn share(&self) -> Self {
593593
let array = unsafe {
594-
Self::from_sys_init_default(|self_ptr| {
594+
Self::from_sys_init(|self_ptr| {
595595
let ctor = ::godot_ffi::builtin_fn!(array_construct_copy);
596596
let args = [self.sys_const()];
597597
ctor(self_ptr, args.as_ptr());
@@ -606,7 +606,7 @@ impl<T: VariantMetadata> Default for TypedArray<T> {
606606
fn default() -> Self {
607607
let mut array = unsafe {
608608
Self::from_sys_init(|self_ptr| {
609-
let ctor = ::godot_ffi::builtin_fn!(array_construct_default);
609+
let ctor = sys::builtin_fn!(array_construct_default);
610610
ctor(self_ptr, std::ptr::null_mut())
611611
})
612612
};

godot-core/src/builtin/dictionary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl fmt::Debug for Dictionary {
271271
impl Share for Dictionary {
272272
fn share(&self) -> Self {
273273
unsafe {
274-
Self::from_sys_init_default(|self_ptr| {
274+
Self::from_sys_init(|self_ptr| {
275275
let ctor = sys::builtin_fn!(dictionary_construct_copy);
276276
let args = [self.sys_const()];
277277
ctor(self_ptr, args.as_ptr());

godot-core/src/builtin/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ macro_rules! impl_builtin_froms {
168168
$(impl From<&$From> for $To {
169169
fn from(other: &$From) -> Self {
170170
unsafe {
171-
Self::from_sys_init_default(|ptr| {
171+
Self::from_sys_init(|ptr| {
172172
let args = [other.sys_const()];
173173
::godot_ffi::builtin_call! {
174174
$from_fn(ptr, args.as_ptr())

0 commit comments

Comments
 (0)