From e68988b287aaa703393719e33107e0b0e6eb0f26 Mon Sep 17 00:00:00 2001 From: chirag-parmar Date: Thu, 31 Oct 2024 20:53:03 +0530 Subject: [PATCH] compare before decrementing --- eth/rlp/writer.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eth/rlp/writer.nim b/eth/rlp/writer.nim index 56362c2..e3a02ba 100644 --- a/eth/rlp/writer.nim +++ b/eth/rlp/writer.nim @@ -65,11 +65,11 @@ proc maybeClosePendingLists(self: var RlpWriter) = let lastListIdx = self.pendingLists.len - 1 doAssert self.pendingLists[lastListIdx].remainingItems > 0 - self.pendingLists[lastListIdx].remainingItems -= 1 # if one last item is remaining in the list - if self.pendingLists[lastListIdx].remainingItems == 0: + if self.pendingLists[lastListIdx].remainingItems == 1: # A list have been just finished. It was started in `startList`. let listStartPos = self.pendingLists[lastListIdx].startPos + self.pendingLists[lastListIdx].remainingItems -= 1 self.pendingLists.setLen lastListIdx # How many bytes were written since the start?