Fix memory leak in unittests with malformed data.
The MalformedZipTest was not calling End() on the extent writer,
leaking memory in the unittest.
Bug: chromium:598967
TEST=USE="clang asan" FEATURES=test emerge-link update_engine
Change-Id: I2d1fefee051d57ac17906e8ea69ba71f43386f0b
diff --git a/payload_generator/zip_unittest.cc b/payload_generator/zip_unittest.cc
index c38f8b8..54adfcb 100644
--- a/payload_generator/zip_unittest.cc
+++ b/payload_generator/zip_unittest.cc
@@ -72,10 +72,11 @@
std::unique_ptr<ExtentWriter> writer(
new W(brillo::make_unique_ptr(new MemoryExtentWriter(out))));
// Init() parameters are ignored by the testing MemoryExtentWriter.
- TEST_AND_RETURN_FALSE(writer->Init(nullptr, {}, 1));
- TEST_AND_RETURN_FALSE(writer->Write(in.data(), in.size()));
- TEST_AND_RETURN_FALSE(writer->End());
- return true;
+ bool ok = writer->Init(nullptr, {}, 1);
+ ok = writer->Write(in.data(), in.size()) && ok;
+ // Call End() even if the Write failed.
+ ok = writer->End() && ok;
+ return ok;
}
} // namespace