mirror of https://github.com/status-im/nim-eth.git
Fix AssertionError on ByteRange slice with nonexistent position
This commit is contained in:
parent
9b69910570
commit
903b72a5c8
|
@ -272,7 +272,14 @@ iterator items*(self: var Rlp): var Rlp =
|
||||||
position = elemEnd
|
position = elemEnd
|
||||||
|
|
||||||
proc listElem*(self: Rlp, i: int): Rlp =
|
proc listElem*(self: Rlp, i: int): Rlp =
|
||||||
let payload = bytes.slice(position + payloadOffset())
|
let
|
||||||
|
payloadOffset = payloadOffset()
|
||||||
|
|
||||||
|
# This will only check if there is some data, not if it is correct according
|
||||||
|
# to list length. Could also run here payloadBytesCount() instead.
|
||||||
|
if position + payloadOffset + 1 > bytes.len: eosError()
|
||||||
|
|
||||||
|
let payload = bytes.slice(position + payloadOffset)
|
||||||
result = rlpFromBytes payload
|
result = rlpFromBytes payload
|
||||||
var pos = 0
|
var pos = 0
|
||||||
while pos < i and result.hasData:
|
while pos < i and result.hasData:
|
||||||
|
|
Loading…
Reference in New Issue