summaryrefslogtreecommitdiff
path: root/platform/linuxbsd
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 /platform/linuxbsd
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 'platform/linuxbsd')
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index 140368987c..86874687ad 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -535,9 +535,8 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
// Issue an error if "mv" failed to move the given resource to the trash can.
if (err != OK || retval != 0) {
ERR_PRINT("move_to_trash: Could not move the resource \"" + path + "\" to the trash can \"" + trash_path + "/files\"");
- DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ DirAccessRef dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
err = dir_access->rename(renamed_path, path);
- memdelete(dir_access);
ERR_FAIL_COND_V_MSG(err != OK, err, "Could not rename \"" + renamed_path + "\" back to its original name: \"" + path + "\"");
return FAILED;
}