From e43d5d5eaabf1700559a3b54475122a1c4a33ba3 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sun, 16 Aug 2020 18:14:20 -0700 Subject: FileManger: Fix file descriptor leak in copy_file_or_directory, found by Coverity --- Applications/FileManager/FileUtils.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Applications') 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 +#include #include #include #include @@ -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) { -- cgit v1.2.3