You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
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>
This commit is contained in:
@@ -414,8 +414,6 @@ Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags, bool p_
|
||||
}
|
||||
|
||||
bool DirAccess::exists(String p_dir) {
|
||||
DirAccess *da = DirAccess::create_for_path(p_dir);
|
||||
bool valid = da->change_dir(p_dir) == OK;
|
||||
memdelete(da);
|
||||
return valid;
|
||||
DirAccessRef da = DirAccess::create_for_path(p_dir);
|
||||
return da->change_dir(p_dir) == OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user