FileManger: Fix file descriptor leak in copy_file_or_directory, found by Coverity

This commit is contained in:
Brian Gianforcaro 2020-08-16 18:14:20 -07:00 committed by Andreas Kling
commit e43d5d5eaa
Notes: sideshowbarker 2024-07-19 03:30:22 +09:00

View file

@ -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) {