Transaction: Fix bounds error getting data address in empty seq
In the unusual case where log data is zero-length, `data[0].addr` is invalid and Nim thoughtfully raises `IndexOutOfBounds`, a `Defect` so it's not even in `CatchableError`. This is done in the EVMC host services to handle `LOG*` ops, and it made one of the EVM tests silently fail with no error message. The fix is obvious. Signed-off-by: Jamie Lokier <jamie@shareable.org>
This commit is contained in:
parent
a5dc0bd283
commit
b734240291
|
@ -212,8 +212,10 @@ proc emitLog(host: TransactionHost, address: HostAddress,
|
|||
for i in 0 ..< count:
|
||||
log.topics[i] = topicsArray[i]
|
||||
|
||||
log.data = newSeq[byte](data_size.int)
|
||||
copyMem(log.data[0].addr, data, data_size.int)
|
||||
if (data_size > 0):
|
||||
log.data = newSeq[byte](data_size.int)
|
||||
copyMem(log.data[0].addr, data, data_size.int)
|
||||
|
||||
log.address = address
|
||||
host.logEntries.add(log)
|
||||
|
||||
|
|
Loading…
Reference in New Issue