diff --git a/ethutil/bytes.go b/ethutil/bytes.go
index 075e40b4c4cc5e264dd6455935d47335623da0c9..1c7a43af8f723eb071ddb34b5d60d14d12f05a9f 100644
--- a/ethutil/bytes.go
+++ b/ethutil/bytes.go
@@ -90,7 +90,7 @@ func IsHex(str string) bool {
 }
 
 func StringToByteFunc(str string, cb func(str string) []byte) (ret []byte) {
-	if str[0:2] == "0x" {
+	if len(str) > 1 && str[0:2] == "0x" {
 		ret = FromHex(str[2:])
 	} else {
 		ret = cb(str)