提交 e1e87d8b 编写于 作者: J Jeffrey Wilcke

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.
上级 10582a97
...@@ -89,18 +89,18 @@ func Hex2BytesFixed(str string, flen int) []byte { ...@@ -89,18 +89,18 @@ func Hex2BytesFixed(str string, flen int) []byte {
} }
func RightPadBytes(slice []byte, l int) []byte { func RightPadBytes(slice []byte, l int) []byte {
if l < len(slice) { if l <= len(slice) {
return slice return slice
} }
padded := make([]byte, l) padded := make([]byte, l)
copy(padded[0:len(slice)], slice) copy(padded, slice)
return padded return padded
} }
func LeftPadBytes(slice []byte, l int) []byte { func LeftPadBytes(slice []byte, l int) []byte {
if l < len(slice) { if l <= len(slice) {
return slice return slice
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册