dexoptanalyzer: fix a potential use of nullptr
If oat_file is nullptr here, we can't `GetLocation()` on it. unsure if
there's more descriptive context to add here.
Caught by the static analyzer:
> art/dexoptanalyzer/dexoptanalyzer.cc:375:47: warning: Called C++
object pointer is null [clang-analyzer-core.CallAndMessage]
Bug: None
Test: TreeHugger
Change-Id: Icdae5de4a4e4ff82ad03a247c53fc9583afdfa5d
diff --git a/dexoptanalyzer/dexoptanalyzer.cc b/dexoptanalyzer/dexoptanalyzer.cc
index 6892a57..14fd62e 100644
--- a/dexoptanalyzer/dexoptanalyzer.cc
+++ b/dexoptanalyzer/dexoptanalyzer.cc
@@ -371,7 +371,11 @@
const auto& image_spaces = runtime->GetHeap()->GetBootImageSpaces();
for (const auto& image_space : image_spaces) {
const OatFile* oat_file = image_space->GetOatFile();
- if (oat_file == nullptr || !ImageSpace::ValidateOatFile(*oat_file, &error_msg)) {
+ if (oat_file == nullptr) {
+ LOG(ERROR) << "NULL oat file encountered";
+ return ReturnCode::kDex2OatFromScratch;
+ }
+ if (!ImageSpace::ValidateOatFile(*oat_file, &error_msg)) {
LOG(ERROR) << "Invalid oat file: " << oat_file->GetLocation() << " " << error_msg;
return ReturnCode::kDex2OatFromScratch;
}