Fix crashes when OTA install fails on non-VABC partition am: 6c0570668f

Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/2391313

Change-Id: Icde5becb1d0da18d4c84ec310844ad8b735929d5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/payload_consumer/partition_writer.cc b/payload_consumer/partition_writer.cc
index 3432c89..d7d8bea 100644
--- a/payload_consumer/partition_writer.cc
+++ b/payload_consumer/partition_writer.cc
@@ -288,7 +288,9 @@
 }
 
 void PartitionWriter::CheckpointUpdateProgress(size_t next_op_index) {
-  target_fd_->Flush();
+  if (target_fd_) {
+    target_fd_->Flush();
+  }
 }
 
 std::unique_ptr<ExtentWriter> PartitionWriter::CreateBaseExtentWriter() {