diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index c8bef9e527..6e93d862ad 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -2541,11 +2541,15 @@ class Dex2Oat final { preloaded_classes_ = std::make_unique>(); if (!preloaded_classes_fds_.empty()) { for (int fd : preloaded_classes_fds_) { - ReadCommentedInputFromFd(fd, nullptr, preloaded_classes_.get()); + if (!ReadCommentedInputFromFd(fd, nullptr, preloaded_classes_.get())) { + return false; + } } } else { for (const std::string& file : preloaded_classes_files_) { - ReadCommentedInputFromFile(file.c_str(), nullptr, preloaded_classes_.get()); + if (!ReadCommentedInputFromFile(file.c_str(), nullptr, preloaded_classes_.get())) { + return false; + } } } return true; @@ -2780,25 +2784,27 @@ class Dex2Oat final { } template - static void ReadCommentedInputFromFile( + static bool ReadCommentedInputFromFile( const char* input_filename, std::function* process, T* output) { auto input_file = std::unique_ptr{fopen(input_filename, "r"), fclose}; if (!input_file) { LOG(ERROR) << "Failed to open input file " << input_filename; - return; + return false; } ReadCommentedInputStream(input_file.get(), process, output); + return true; } template - static void ReadCommentedInputFromFd( + static bool ReadCommentedInputFromFd( int input_fd, std::function* process, T* output) { auto input_file = std::unique_ptr{fdopen(input_fd, "r"), fclose}; if (!input_file) { LOG(ERROR) << "Failed to re-open input fd from /prof/self/fd/" << input_fd; - return; + return false; } ReadCommentedInputStream(input_file.get(), process, output); + return true; } // Read lines from the given file, dropping comments and empty lines. Post-process each line with