Skip to content

Commit

Permalink
Fix issue buger#188
Browse files Browse the repository at this point in the history
  • Loading branch information
willson-chen committed Mar 17, 2020
1 parent 1a29609 commit 9584947
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,16 @@ func findKeyStart(data []byte, key string) (int, error) {
}

case '[':
i = blockEnd(data[i:], data[i], ']') + i
ret = blockEnd(data[i:], data[i], ']')
if ret != -1 {
i = i + ret
}

case '{':
i = blockEnd(data[i:], data[i], '}') + i
ret = blockEnd(data[i:], data[i], '}')
if ret != -1 {
ret = i + ret
}
}
i++
}
Expand Down
6 changes: 6 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ var deleteTests = []DeleteTest{
path: []string{"b"},
data: `{"a": "1" , "c": 3}`,
},
{
desc: "Issue #188: infinite loop in Delete",
json: `"^_�^C^A^@[{"`,
path: []string{""},
data: `"^_�^C^A^@[{"`,
},
}

var setTests = []SetTest{
Expand Down

0 comments on commit 9584947

Please sign in to comment.