diff options
author | Brian Gianforcaro <b.gianfo@gmail.com> | 2020-08-16 18:14:20 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-17 09:17:57 +0200 |
commit | e43d5d5eaabf1700559a3b54475122a1c4a33ba3 (patch) | |
tree | ff10028d8db8e17c94401b5c843e2c5bdb81bb18 | |
parent | bcbac83a8bdd2ca29f70204d6c7d8202d6b01bdf (diff) | |
download | serenity-e43d5d5eaabf1700559a3b54475122a1c4a33ba3.zip |
FileManger: Fix file descriptor leak in copy_file_or_directory, found by Coverity
-rw-r--r-- | Applications/FileManager/FileUtils.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Applications/FileManager/FileUtils.cpp b/Applications/FileManager/FileUtils.cpp index 20187415d7..7ba59f063b 100644 --- a/Applications/FileManager/FileUtils.cpp +++ b/Applications/FileManager/FileUtils.cpp @@ -26,6 +26,7 @@ #include "FileUtils.h" #include <AK/LexicalPath.h> +#include <AK/ScopeGuard.h> #include <AK/StringBuilder.h> #include <LibCore/DirIterator.h> #include <stdio.h> @@ -86,6 +87,8 @@ bool copy_file_or_directory(const String& src_path, const String& dst_path) return false; } + ScopeGuard close_fd_guard([src_fd]() { close(src_fd); }); + struct stat src_stat; int rc = fstat(src_fd, &src_stat); if (rc < 0) { |