Make DexFile content read only before running DexFileVerifier
Change-Id: I806d08112cdc5a79e91c97991fff02686a5f9784
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 9cb2f1b..3ff55ab 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -258,15 +258,15 @@
error_msg->c_str());
return nullptr;
}
- if (!DexFileVerifier::Verify(dex_file.get(), dex_file->Begin(), dex_file->Size(),
- location.c_str(), error_msg)) {
- return nullptr;
- }
if (!dex_file->DisableWrite()) {
*error_msg = StringPrintf("Failed to make dex file '%s' read only", location.c_str());
return nullptr;
}
CHECK(dex_file->IsReadOnly()) << location;
+ if (!DexFileVerifier::Verify(dex_file.get(), dex_file->Begin(), dex_file->Size(),
+ location.c_str(), error_msg)) {
+ return nullptr;
+ }
return dex_file.release();
}