From ada8dfa4a7eab70755cc5210026f23e394358d13 Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Mon, 10 Apr 2023 14:19:23 -0400 Subject: [PATCH] ios: Always reset IOSIntermediateDumpWriter file descriptor on close. Always reset the file descriptor to -1, even if FlushWriteBuffer or RawLoggingCloseFile fails. Bug: 1431760 Change-Id: I193f526d65f477bba002dd9faf68996020e48a3b Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4406657 Reviewed-by: Ben Hamilton Commit-Queue: Justin Cohen Reviewed-by: Robert Sesek --- util/ios/ios_intermediate_dump_writer.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/util/ios/ios_intermediate_dump_writer.cc b/util/ios/ios_intermediate_dump_writer.cc index bccd1539..c180fc08 100644 --- a/util/ios/ios_intermediate_dump_writer.cc +++ b/util/ios/ios_intermediate_dump_writer.cc @@ -83,12 +83,10 @@ bool IOSIntermediateDumpWriter::Close() { if (fd_ < 0) { return true; } - if (!FlushWriteBuffer()) { - return false; - } - int fd = fd_; + const bool flushed = FlushWriteBuffer(); + const bool closed = RawLoggingCloseFile(fd_); fd_ = -1; - return RawLoggingCloseFile(fd); + return flushed && closed; } bool IOSIntermediateDumpWriter::AddPropertyCString(IntermediateDumpKey key,