cmd/disasm: fix off-by-one error and improve error handling (#3482)

This commit is contained in:
Valentin Wüstholz 2016-12-22 00:37:27 +01:00 committed by Felix Lange
parent 9a51f5c350
commit bdaa43510b

View File

@ -21,8 +21,9 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"encoding/hex"
"strings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/core/vm"
) )
@ -32,7 +33,11 @@ func main() {
fmt.Println(err) fmt.Println(err)
os.Exit(1) 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) fmt.Printf("%x\n", code)
for pc := uint64(0); pc < uint64(len(code)); pc++ { for pc := uint64(0); pc < uint64(len(code)); pc++ {