mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Fix file descriptor/handle leak in LoggingReadEntireFile()
8af3203d811c introduced a resource leak. Change-Id: Ia909eef39b6b772d8808dd6f5770c06add6467bc Reviewed-on: https://chromium-review.googlesource.com/493946 Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
parent
51779ce639
commit
abbeffead9
@ -157,15 +157,16 @@ void CheckedReadFileAtEOF(FileHandle file) {
|
||||
}
|
||||
|
||||
bool LoggingReadEntireFile(const base::FilePath& path, std::string* contents) {
|
||||
FileHandle handle = LoggingOpenFileForRead(path);
|
||||
if (handle == kInvalidFileHandle) {
|
||||
ScopedFileHandle handle(LoggingOpenFileForRead(path));
|
||||
if (!handle.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char buffer[4096];
|
||||
FileOperationResult rv;
|
||||
std::string local_contents;
|
||||
while ((rv = ReadFile(handle, buffer, sizeof(buffer))) > 0) {
|
||||
while ((rv = ReadFile(handle.get(), buffer, sizeof(buffer))) > 0) {
|
||||
DCHECK_LE(static_cast<size_t>(rv), sizeof(buffer));
|
||||
local_contents.append(buffer, rv);
|
||||
}
|
||||
if (rv < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user