Skip to content

Commit

Permalink
fix BinaryToSlice index out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhailin-Leo committed Mar 29, 2023
1 parent 0ec5d77 commit 0d863ce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion utils/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ func BinaryToSlice(body []uint8, bytesLen int, returnType string) []interface{}
convertFuncResult := make([]interface{}, cap(body)/bytesLen)
for i := 0; i < len(convertFuncResult); i++ {
if i*bytesLen+bytesLen > len(body) {
convertFuncResult[i] = convertFunc(body[i*bytesLen:])
if len(body[i*bytesLen:]) > 0 {
convertFuncResult[i] = convertFunc(body[i*bytesLen:])
}
break
} else {
convertFuncResult[i] = convertFunc(body[i*bytesLen : i*bytesLen+bytesLen])
}
Expand Down

0 comments on commit 0d863ce

Please sign in to comment.