From e1e87d8b1aebe88354e2f64ffd031709524522e4 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 23 May 2017 11:15:49 +0200 Subject: [PATCH] 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. --- common/bytes.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/bytes.go b/common/bytes.go index 0342083a1..c445968f2 100644 --- a/common/bytes.go +++ b/common/bytes.go @@ -89,18 +89,18 @@ func Hex2BytesFixed(str string, flen int) []byte { } func RightPadBytes(slice []byte, l int) []byte { - if l < len(slice) { + if l <= len(slice) { return slice } padded := make([]byte, l) - copy(padded[0:len(slice)], slice) + copy(padded, slice) return padded } func LeftPadBytes(slice []byte, l int) []byte { - if l < len(slice) { + if l <= len(slice) { return slice }