Merge "Fix memory leak in hiddenapi_test"
diff --git a/tools/hiddenapi/hiddenapi_test.cc b/tools/hiddenapi/hiddenapi_test.cc
index 1f37f40..6348405 100644
--- a/tools/hiddenapi/hiddenapi_test.cc
+++ b/tools/hiddenapi/hiddenapi_test.cc
@@ -46,12 +46,13 @@
const std::vector<std::string>& extra_args,
ScratchFile* out_dex) {
std::string error;
- ZipArchive* jar = ZipArchive::Open(GetTestDexFileName("HiddenApi").c_str(), &error);
+ std::unique_ptr<ZipArchive> jar(
+ ZipArchive::Open(GetTestDexFileName("HiddenApi").c_str(), &error));
if (jar == nullptr) {
LOG(FATAL) << "Could not open test file " << GetTestDexFileName("HiddenApi") << ": " << error;
UNREACHABLE();
}
- ZipEntry* jar_classes_dex = jar->Find("classes.dex", &error);
+ std::unique_ptr<ZipEntry> jar_classes_dex(jar->Find("classes.dex", &error));
if (jar_classes_dex == nullptr) {
LOG(FATAL) << "Could not find classes.dex in test file " << GetTestDexFileName("HiddenApi")
<< ": " << error;