Merge "Fix to return null if dex file fails verification." into dalvik-dev
diff --git a/src/dex_file.cc b/src/dex_file.cc
index 974f6e5..cb90e15 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -135,9 +135,16 @@
}
close(fd);
const DexFile* dex_file = OpenMemory(location, map.release());
- if (dex_file != NULL) {
- DexFileVerifier::Verify(dex_file, dex_file->Begin(), dex_file->Size());
+ if (dex_file == NULL) {
+ LOG(ERROR) << "Failed to open dex file '" << location << "' from memory";
+ return NULL;
}
+
+ if (!DexFileVerifier::Verify(dex_file, dex_file->Begin(), dex_file->Size())) {
+ LOG(ERROR) << "Failed to verify dex file '" << location << "'";
+ return NULL;
+ }
+
return dex_file;
}
@@ -183,9 +190,16 @@
}
const DexFile* dex_file = OpenMemory(location, map.release());
- if (dex_file != NULL) {
- DexFileVerifier::Verify(dex_file, dex_file->Begin(), dex_file->Size());
+ if (dex_file == NULL) {
+ LOG(ERROR) << "Failed to open dex file '" << location << "' from memory";
+ return NULL;
}
+
+ if (!DexFileVerifier::Verify(dex_file, dex_file->Begin(), dex_file->Size())) {
+ LOG(ERROR) << "Failed to verify dex file '" << location << "'";
+ return NULL;
+ }
+
return dex_file;
}