From 858273bc89e620fad7c18e477c6739a6e0598e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 9 Jan 2015 17:23:10 +0100 Subject: [PATCH] Handle return memory of size 0 and large offset --- libevmjit/Runtime.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libevmjit/Runtime.cpp b/libevmjit/Runtime.cpp index 2522e8ace..911dc469d 100644 --- a/libevmjit/Runtime.cpp +++ b/libevmjit/Runtime.cpp @@ -24,8 +24,10 @@ bytes Runtime::getReturnData() const // FIXME: Reconsider returning by copy auto offset = static_cast(llvm2eth(m_data.elems[RuntimeData::ReturnDataOffset])); auto size = static_cast(llvm2eth(m_data.elems[RuntimeData::ReturnDataSize])); - assert(offset + size <= m_memory.size()); - // TODO: Handle invalid data access by returning empty ref + assert(offset + size <= m_memory.size() || size == 0); + if (offset + size > m_memory.size()) + return {}; + auto dataBeg = m_memory.begin() + offset; return {dataBeg, dataBeg + size}; }