summaryrefslogtreecommitdiff
path: root/modules/mono/mono_gd/gd_mono.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-03-10 15:27:09 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-03-11 09:13:11 +0100
commit768f9422bc3b1349729b8a50feb8c0797003aee9 (patch)
treeccc2863deb916a604b39cf67f897b32edcdfc4da /modules/mono/mono_gd/gd_mono.cpp
parent259114e9e0d5bb01d023ad978e06ed14ca785b1d (diff)
Convert uses of `DirAccess *` to `DirAccessRef` to prevent memleaks
`DirAccess *` needs to be deleted manually, and this is often forgotten especially when doing early returns with `ERR_FAIL_COND`. `DirAccessRef` is deleted automatically when it goes out of scope. Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
Diffstat (limited to 'modules/mono/mono_gd/gd_mono.cpp')
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 4cd4772d2c..424b74906f 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -643,9 +643,8 @@ bool GDMono::copy_prebuilt_api_assembly(ApiAssemblyInfo::Type p_api_type, const
// Create destination directory if needed
if (!DirAccess::exists(dst_dir)) {
- DirAccess *da = DirAccess::create_for_path(dst_dir);
+ DirAccessRef da = DirAccess::create_for_path(dst_dir);
Error err = da->make_dir_recursive(dst_dir);
- memdelete(da);
if (err != OK) {
ERR_PRINT("Failed to create destination directory for the API assemblies. Error: " + itos(err) + ".");