From 261d3a8d291eb422e195edfdf346e3c19991c981 Mon Sep 17 00:00:00 2001 From: hunshenshi <289517357@qq.com> Date: Tue, 19 Mar 2024 18:42:15 +0800 Subject: [PATCH] feat(api): fix overflow in coreservice --- api/coreservice.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/coreservice.go b/api/coreservice.go index 3fbfd3ad85..d83bf4f79d 100644 --- a/api/coreservice.go +++ b/api/coreservice.go @@ -1318,10 +1318,9 @@ func (core *coreService) reverseActionsInBlock(blk *block.Block, reverseStart, c if reverseStart > size || count == 0 { return nil } - // TODO (saito): fix overflow - start := size - (reverseStart + count) - if start < 0 { - start = 0 + start := uint64(0) + if size > reverseStart+count { + start = size - (reverseStart + count) } end := size - 1 - reverseStart res := make([]*iotexapi.ActionInfo, 0, start-end+1)