1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

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
parent bcbac83a8b
commit e43d5d5eaa

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