From d12f9c13599a6b5893cffd02c9b8d35b4db93bf3 Mon Sep 17 00:00:00 2001 From: "Serdjuk, Nikolay Y" Date: Tue, 22 Mar 2016 10:06:33 +0600 Subject: [PATCH] ART: Save or erase the file even if I/O failed It should close the file in any case. Change-Id: Idb7db15bfecb0ac47839be3544cc2dce91096d7b Signed-off-by: Serdjuk, Nikolay Y --- patchoat/patchoat.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index 63ae342e1..a1b3c9e12 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -320,11 +320,11 @@ bool PatchOat::Patch(const std::string& image_location, PatchOat& p = space_to_patchoat_map.find(space)->second; - if (!p.WriteImage(output_image_file.get())) { - LOG(ERROR) << "Failed to write image file " << output_image_file->GetPath(); + bool success = p.WriteImage(output_image_file.get()); + success = FinishFile(output_image_file.get(), success); + if (!success) { return false; } - FinishFile(output_image_file.get(), true); bool skip_patching_oat = space_to_skip_patching_map.find(space)->second; if (!skip_patching_oat) { @@ -336,11 +336,11 @@ bool PatchOat::Patch(const std::string& image_location, LOG(ERROR) << "Failed to open output oat file at " << output_oat_filename; return false; } - if (!p.WriteElf(output_oat_file.get())) { - LOG(ERROR) << "Failed to write oat file " << output_oat_file->GetPath(); + success = p.WriteElf(output_oat_file.get()); + success = FinishFile(output_oat_file.get(), success); + if (!success) { return false; } - FinishFile(output_oat_file.get(), true); } } return true; -- 2.11.0