Skip to content

Commit ed9f332

Browse files
committed
Fix one case of infinite looping
1 parent 7f449b2 commit ed9f332

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/HJSON/HJSONParser.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,11 @@ private function next($c = false)
345345
private function peek($offs)
346346
{
347347
// range check is not required
348-
return mb_substr(mb_strcut($this->text, $this->at), $offs, 1);
348+
if ($offs >= 0) {
349+
return mb_substr(mb_strcut($this->text, $this->at), $offs, 1);
350+
} else {
351+
return mb_substr(mb_strcut($this->text, 0, $this->at), $offs, 1);
352+
}
349353
}
350354

351355
private function skipIndent($indent)

0 commit comments

Comments
 (0)