aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValentin Wüstholz <wuestholz@users.noreply.github.com>2016-12-22 07:37:27 +0800
committerFelix Lange <fjl@users.noreply.github.com>2016-12-22 07:37:27 +0800
commitbdaa43510b294bf49bbac1392d5518611c06eedc (patch)
tree1b88522b6b154533a7b0a07aa093befde34ba41b
parent9a51f5c3506ed644e4e24f879cbb1ae7098f6dbc (diff)
downloadgo-tangerine-bdaa43510b294bf49bbac1392d5518611c06eedc.tar
go-tangerine-bdaa43510b294bf49bbac1392d5518611c06eedc.tar.gz
go-tangerine-bdaa43510b294bf49bbac1392d5518611c06eedc.tar.bz2
go-tangerine-bdaa43510b294bf49bbac1392d5518611c06eedc.tar.lz
go-tangerine-bdaa43510b294bf49bbac1392d5518611c06eedc.tar.xz
go-tangerine-bdaa43510b294bf49bbac1392d5518611c06eedc.tar.zst
go-tangerine-bdaa43510b294bf49bbac1392d5518611c06eedc.zip
cmd/disasm: fix off-by-one error and improve error handling (#3482)
-rw-r--r--cmd/disasm/main.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd/disasm/main.go b/cmd/disasm/main.go
index ba1295ba1..d792e8ee5 100644
--- a/cmd/disasm/main.go
+++ b/cmd/disasm/main.go
@@ -21,8 +21,9 @@ import (
"fmt"
"io/ioutil"
"os"
+ "encoding/hex"
+ "strings"
- "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
)
@@ -32,7 +33,11 @@ func main() {
fmt.Println(err)
os.Exit(1)
}
- code = common.Hex2Bytes(string(code[:len(code)-1]))
+ code, err = hex.DecodeString(strings.TrimSpace(string(code[:])))
+ if err != nil {
+ fmt.Printf("Error: %v\n", err)
+ return
+ }
fmt.Printf("%x\n", code)
for pc := uint64(0); pc < uint64(len(code)); pc++ {