File lister: Fix possible resource leaks (#5031)
Trac ticket created: #11703 Found by Coverity: CID 1474932
This commit is contained in:
parent
46b9d4ec61
commit
07b802fd2a
|
@ -230,15 +230,19 @@ static std::string addFiles2(std::map<std::string, std::size_t> &files,
|
|||
if (path_is_directory) {
|
||||
if (recursive && !ignored.match(new_path)) {
|
||||
std::string err = addFiles2(files, new_path, extra, recursive, ignored);
|
||||
if (!err.empty())
|
||||
if (!err.empty()) {
|
||||
closedir(dir);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Path::acceptFile(new_path, extra) && !ignored.match(new_path)) {
|
||||
if (stat(new_path.c_str(), &file_stat) != -1)
|
||||
files[new_path] = file_stat.st_size;
|
||||
else
|
||||
else {
|
||||
closedir(dir);
|
||||
return "Can't stat " + new_path + " errno: " + std::to_string(errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue