Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix memory leak of a `ScannedDirectory` instance in `EditorFileSystem`

Aaron Franke7ffa15ca9f35
diff --git a/editor/file_system/editor_file_system.cpp b/editor/file_system/editor_file_system.cpp
index c8e41ba0560..3ee46747eb2 100644
--- a/editor/file_system/editor_file_system.cpp
+++ b/editor/file_system/editor_file_system.cpp
@@ -534,7 +534,9 @@ void EditorFileSystem::_scan_filesystem() {
first_scan_root_dir = nullptr;
memdelete(processed_files);
} else {
- //on the first scan this is done from the main thread after re-importing
+ // A local `sd` is created only on non-first scan, otherwise `sd` is not owned by this function.
+ memdelete(sd);
+ // On the first scan this is done from the main thread after re-importing.
_save_filesystem_cache();
}