Skip to content

Commit e1e87d8

Browse files
committed
common: fixed byte padding functions
Byte padding function should return the given slice if the length is smaller or equal rather than *only* smaller than. This fix improves almost all EVM push operations.
1 parent 10582a9 commit e1e87d8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

common/bytes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,18 @@ func Hex2BytesFixed(str string, flen int) []byte {
8989
}
9090

9191
func RightPadBytes(slice []byte, l int) []byte {
92-
if l < len(slice) {
92+
if l <= len(slice) {
9393
return slice
9494
}
9595

9696
padded := make([]byte, l)
97-
copy(padded[0:len(slice)], slice)
97+
copy(padded, slice)
9898

9999
return padded
100100
}
101101

102102
func LeftPadBytes(slice []byte, l int) []byte {
103-
if l < len(slice) {
103+
if l <= len(slice) {
104104
return slice
105105
}
106106

0 commit comments

Comments
 (0)