From b7342402916c52940980178276e4c93d5772f36e Mon Sep 17 00:00:00 2001 From: Jamie Lokier Date: Mon, 24 May 2021 09:53:53 +0100 Subject: [PATCH] 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 --- nimbus/transaction/host_services.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nimbus/transaction/host_services.nim b/nimbus/transaction/host_services.nim index 8440c8e49..67cdfc6a9 100644 --- a/nimbus/transaction/host_services.nim +++ b/nimbus/transaction/host_services.nim @@ -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)