Skip to content

Commit e6a2cf9

Browse files
byroothsbt
authored andcommitted
[ruby/json] Fix potential out of bound read in json_string_unescape.
ruby/json@cf242d89a0
1 parent 8cc85dc commit e6a2cf9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/json/parser/parser.c

Lines changed: 1 addition & 1 deletion
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)