Browse Source

Handle return memory of size 0 and large offset

cl-refactor
Paweł Bylica 10 years ago
parent
commit
858273bc89
  1. 6
      libevmjit/Runtime.cpp

6
libevmjit/Runtime.cpp

@ -24,8 +24,10 @@ bytes Runtime::getReturnData() const // FIXME: Reconsider returning by copy
auto offset = static_cast<size_t>(llvm2eth(m_data.elems[RuntimeData::ReturnDataOffset])); auto offset = static_cast<size_t>(llvm2eth(m_data.elems[RuntimeData::ReturnDataOffset]));
auto size = static_cast<size_t>(llvm2eth(m_data.elems[RuntimeData::ReturnDataSize])); auto size = static_cast<size_t>(llvm2eth(m_data.elems[RuntimeData::ReturnDataSize]));
assert(offset + size <= m_memory.size()); assert(offset + size <= m_memory.size() || size == 0);
// TODO: Handle invalid data access by returning empty ref if (offset + size > m_memory.size())
return {};
auto dataBeg = m_memory.begin() + offset; auto dataBeg = m_memory.begin() + offset;
return {dataBeg, dataBeg + size}; return {dataBeg, dataBeg + size};
} }

Loading…
Cancel
Save