Skip to content

Commit 645e477

Browse files
committed
Ensure OpenDexFilesFromImage closes file to prevent file descriptor leak
Test: m -j32 test-art-host Bug: 32095919 Change-Id: I44541edeb403a508e1b9794ee09fb1f55e3f42bf
1 parent 47d522b commit 645e477

File tree

7 files changed

+160
-149
lines changed

7 files changed

+160
-149
lines changed

compiler/elf_writer_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ TEST_F(ElfWriterTest, dlsym) {
9494
/*low_4gb*/false,
9595
&error_msg));
9696
CHECK(ef.get() != nullptr) << error_msg;
97-
CHECK(ef->Load(false, /*low_4gb*/false, &error_msg)) << error_msg;
97+
CHECK(ef->Load(file.get(), false, /*low_4gb*/false, &error_msg)) << error_msg;
9898
EXPECT_EQ(dl_oatdata, ef->FindDynamicSymbolAddress("oatdata"));
9999
EXPECT_EQ(dl_oatexec, ef->FindDynamicSymbolAddress("oatexec"));
100100
EXPECT_EQ(dl_oatlastword, ef->FindDynamicSymbolAddress("oatlastword"));

patchoat/patchoat.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ PatchOat::MaybePic PatchOat::IsOatPic(const ElfFile* oat_in) {
401401
return ERROR_OAT_FILE;
402402
}
403403

404-
const std::string& file_path = oat_in->GetFile().GetPath();
404+
const std::string& file_path = oat_in->GetFilePath();
405405

406406
const OatHeader* oat_header = GetOatHeader(oat_in);
407407
if (oat_header == nullptr) {
@@ -804,18 +804,19 @@ bool PatchOat::PatchOatHeader(ElfFileImpl* oat_file) {
804804
}
805805
OatHeader* oat_header = reinterpret_cast<OatHeader*>(oat_file->Begin() + rodata_sec->sh_offset);
806806
if (!oat_header->IsValid()) {
807-
LOG(ERROR) << "Elf file " << oat_file->GetFile().GetPath() << " has an invalid oat header";
807+
LOG(ERROR) << "Elf file " << oat_file->GetFilePath() << " has an invalid oat header";
808808
return false;
809809
}
810810
oat_header->RelocateOat(delta_);
811811
return true;
812812
}
813813

814814
bool PatchOat::PatchElf() {
815-
if (oat_file_->Is64Bit())
815+
if (oat_file_->Is64Bit()) {
816816
return PatchElf<ElfFileImpl64>(oat_file_->GetImpl64());
817-
else
817+
} else {
818818
return PatchElf<ElfFileImpl32>(oat_file_->GetImpl32());
819+
}
819820
}
820821

821822
template <typename ElfFileImpl>

0 commit comments

Comments
 (0)