From c156f6809245c347baacd3e7bc9466d09609ca82 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sun, 10 Sep 2017 12:16:17 +0200 Subject: [PATCH] accounts/abi: simplify readBool No other read* function checks the length, so don't do it in readBool. --- accounts/abi/unpack.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go index 5887907f2d..ffa14ccd3b 100644 --- a/accounts/abi/unpack.go +++ b/accounts/abi/unpack.go @@ -60,12 +60,8 @@ func readInteger(kind reflect.Kind, b []byte) interface{} { // reads a bool func readBool(word []byte) (bool, error) { - if len(word) != 32 { - return false, fmt.Errorf("abi: fatal error: incorrect word length") - } - - for i, b := range word { - if b != 0 && i != 31 { + for _, b := range word[:31] { + if b != 0 { return false, errBadBool } }