summaryrefslogtreecommitdiff
path: root/patchoat
diff options
context:
space:
mode:
Diffstat (limited to 'patchoat')
-rw-r--r--patchoat/patchoat.cc2
-rw-r--r--patchoat/patchoat_test.cc7
2 files changed, 8 insertions, 1 deletions
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc
index b9a9a69ab59..dc9d990e299 100644
--- a/patchoat/patchoat.cc
+++ b/patchoat/patchoat.cc
@@ -700,6 +700,7 @@ bool PatchOat::Verify(const std::string& image_location,
}
bool PatchOat::WriteImage(File* out) {
+ CHECK(out != nullptr);
TimingLogger::ScopedTiming t("Writing image File", timings_);
std::string error_msg;
@@ -709,7 +710,6 @@ bool PatchOat::WriteImage(File* out) {
true /* read_only_mode */, &error_msg);
CHECK(image_ != nullptr);
- CHECK(out != nullptr);
size_t expect = image_->Size();
if (out->WriteFully(reinterpret_cast<char*>(image_->Begin()), expect) &&
out->SetLength(expect) == 0) {
diff --git a/patchoat/patchoat_test.cc b/patchoat/patchoat_test.cc
index 974ed3217d1..69728ae0512 100644
--- a/patchoat/patchoat_test.cc
+++ b/patchoat/patchoat_test.cc
@@ -24,6 +24,7 @@
#include "android-base/stringprintf.h"
#include "android-base/strings.h"
+#include "base/hex_dump.h"
#include "base/leb128.h"
#include "dexopt_test.h"
#include "runtime.h"
@@ -320,6 +321,12 @@ class PatchoatTest : public DexoptTest {
if (image1[i] != image2[i]) {
*error_msg =
StringPrintf("%s and %s differ at offset %zu", filename1.c_str(), filename2.c_str(), i);
+ size_t hexdump_size = std::min<size_t>(16u, size - i);
+ HexDump dump1(&image1[i], hexdump_size, /* show_actual_addresses */ false, /* prefix */ "");
+ HexDump dump2(&image2[i], hexdump_size, /* show_actual_addresses */ false, /* prefix */ "");
+ std::ostringstream oss;
+ oss << "\n" << dump1 << "\n" << dump2;
+ *error_msg += oss.str();
return true;
}
}