diff options
| -rw-r--r-- | dexlayout/compact_dex_writer.h | 3 | ||||
| -rw-r--r-- | dexlayout/dex_writer.h | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/dexlayout/compact_dex_writer.h b/dexlayout/compact_dex_writer.h index 4834bfc3af..24d0fbf61d 100644 --- a/dexlayout/compact_dex_writer.h +++ b/dexlayout/compact_dex_writer.h @@ -60,11 +60,14 @@ class CompactDexWriter : public DexWriter { return false; } const uint8_t* data = Data(); + DCHECK_LE(a.offset_ + a.length_, section_->Size()); + DCHECK_LE(b.offset_ + b.length_, section_->Size()); return std::equal(data + a.offset_, data + a.offset_ + a.length_, data + b.offset_); } // Hash function. size_t operator()(const HashedMemoryRange& range) const { + DCHECK_LE(range.offset_ + range.length_, section_->Size()); return HashBytes(Data() + range.offset_, range.length_); } diff --git a/dexlayout/dex_writer.h b/dexlayout/dex_writer.h index e6e05334e4..dd613ed688 100644 --- a/dexlayout/dex_writer.h +++ b/dexlayout/dex_writer.h @@ -85,6 +85,7 @@ class DexWriter { void Seek(size_t position) { position_ = position; + EnsureStorage(0u); } // Does not allow overwriting for bug prevention purposes. @@ -129,10 +130,12 @@ class DexWriter { ALWAYS_INLINE void AlignTo(const size_t alignment) { position_ = RoundUp(position_, alignment); + EnsureStorage(0u); } ALWAYS_INLINE void Skip(const size_t count) { position_ += count; + EnsureStorage(0u); } class ScopedSeek { |