Skip to content

Commit 1dc7c82

Browse files
author
willson-chen
committed
Fix issue buger#188
1 parent 1a29609 commit 1dc7c82

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

parser.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,16 @@ func findKeyStart(data []byte, key string) (int, error) {
9898
}
9999

100100
case '[':
101-
i = blockEnd(data[i:], data[i], ']') + i
101+
ret = blockEnd(data[i:], data[i], ']')
102+
if ret != -1 {
103+
i = i + ret
104+
}
105+
102106
case '{':
103-
i = blockEnd(data[i:], data[i], '}') + i
107+
ret = blockEnd(data[i:], data[i], '}')
108+
if ret != -1 {
109+
ret = i + ret
110+
}
104111
}
105112
i++
106113
}

parser_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,18 @@ var deleteTests = []DeleteTest{
185185
path: []string{"b"},
186186
data: `{"a": "1" , "c": 3}`,
187187
},
188+
{
189+
desc: "Issue #188: infinite loop in Delete",
190+
json: `"^_�^C^A^@["`,
191+
path: []string{""},
192+
data: `"^_�^C^A^@["`,
193+
},
194+
{
195+
desc: "Issue #188: infinite loop in Delete",
196+
json: `"^_�^C^A^@{"`,
197+
path: []string{""},
198+
data: `"^_�^C^A^@{"`,
199+
}
188200
}
189201

190202
var setTests = []SetTest{

0 commit comments

Comments
 (0)