ART: Follow-up changes to DexFileVerifier
Address comments.
Bug: 78568168
Test: m test-art-host
Change-Id: I9649f4342986995bf2aeb83e89c1ea74a9d9b74b
diff --git a/libdexfile/dex/dex_file_verifier.cc b/libdexfile/dex/dex_file_verifier.cc
index 2380f48..ba65fc9 100644
--- a/libdexfile/dex/dex_file_verifier.cc
+++ b/libdexfile/dex/dex_file_verifier.cc
@@ -615,7 +615,7 @@
uint32_t code_offset,
ClassDataItemIterator* direct_it,
bool expect_direct) {
- DCHECK(expect_direct || direct_it != nullptr);
+ DCHECK_EQ(expect_direct, direct_it == nullptr);
// Check for overflow.
if (!CheckIndex(idx, header_->method_ids_size_, "class_data_item method_idx")) {
return false;
@@ -1252,9 +1252,10 @@
uint32_t* handler_offsets;
constexpr size_t kAllocaMaxSize = 1024;
if (handlers_size < kAllocaMaxSize/sizeof(uint32_t)) {
+ // Note: Clang does not specify alignment guarantees for alloca. So align by hand.
handler_offsets =
- AlignDown(reinterpret_cast<uint32_t*>(alloca((handlers_size + 1) * sizeof(uint32_t))),
- alignof(uint32_t[]));
+ AlignUp(reinterpret_cast<uint32_t*>(alloca((handlers_size + 1) * sizeof(uint32_t))),
+ alignof(uint32_t[]));
} else {
handler_offsets_uptr.reset(new uint32_t[handlers_size]);
handler_offsets = handler_offsets_uptr.get();