Check for null of cow_writer_ before call Finalize() am: 6a4d1ec1d0 am: 904efb9d95
Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/1576643
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: Icad0b19c0b926f02714ed68d72e649d5b60ff2c4
diff --git a/payload_consumer/vabc_partition_writer.cc b/payload_consumer/vabc_partition_writer.cc
index 2479132..aa8c3ce 100644
--- a/payload_consumer/vabc_partition_writer.cc
+++ b/payload_consumer/vabc_partition_writer.cc
@@ -153,17 +153,23 @@
void VABCPartitionWriter::CheckpointUpdateProgress(size_t next_op_index) {
// No need to call fsync/sync, as CowWriter flushes after a label is added
// added.
+ // if cow_writer_ failed, that means Init() failed. This function shouldn't be
+ // called if Init() fails.
+ TEST_AND_RETURN(cow_writer_ != nullptr);
cow_writer_->AddLabel(next_op_index);
}
[[nodiscard]] bool VABCPartitionWriter::FinishedInstallOps() {
// Add a hardcoded magic label to indicate end of all install ops. This label
// is needed by filesystem verification, don't remove.
+ TEST_AND_RETURN_FALSE(cow_writer_ != nullptr);
return cow_writer_->AddLabel(kEndOfInstallLabel);
}
VABCPartitionWriter::~VABCPartitionWriter() {
- cow_writer_->Finalize();
+ if (cow_writer_) {
+ cow_writer_->Finalize();
+ }
}
} // namespace chromeos_update_engine