fix for single element json array

This commit is contained in:
William Banfield
2021-07-23 18:05:55 -04:00
parent 0e22c88229
commit 9212ad7c7f
2 changed files with 4 additions and 3 deletions
+3 -3
View File
@@ -43,7 +43,7 @@ func Fuzz(data []byte) int {
return 1
}
if inputJSONIsSlice(data) {
if inputJSONIsMultiElementSlice(data) {
recv := []types.RPCResponse{}
if err := json.Unmarshal(blob, &recv); err != nil {
panic(err)
@@ -57,8 +57,8 @@ func Fuzz(data []byte) int {
return 1
}
func inputJSONIsSlice(input []byte) bool {
func inputJSONIsMultiElementSlice(input []byte) bool {
slice := []interface{}{}
err := json.Unmarshal(input, &slice)
return err == nil
return err == nil && len(slice) > 1
}
@@ -0,0 +1 @@
[0]