Skip to content

Commit c56db31

Browse files
committed
Merge commit from fork
Fix potential out of bound read in `json_string_unescape`.
2 parents 57911f1 + cf242d8 commit c56db31

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changes
22

3+
* Fix a potential crash in the C extension parser.
34
* Raise a ParserError on all incomplete unicode escape sequence. This was the behavior until `2.10.0` unadvertently changed it.
45
* Ensure document snippets that are included in parser errors don't include truncated multibyte characters.
56

ext/json/ext/parser/parser.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ static VALUE json_string_unescape(JSON_ParserState *state, const char *string, c
608608
buffer = RSTRING_PTR(result);
609609
bufferStart = buffer;
610610

611-
while ((pe = memchr(pe, '\\', stringEnd - pe))) {
611+
while (pe < stringEnd && (pe = memchr(pe, '\\', stringEnd - pe))) {
612612
unescape = (char *) "?";
613613
unescape_len = 1;
614614
if (pe > p) {

0 commit comments

Comments
 (0)