summaryrefslogtreecommitdiff
path: root/ext/json/parser
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2025-12-04 09:06:10 +0100
committergit <svn-admin@ruby-lang.org>2025-12-04 08:10:41 +0000
commitd58a45d32ffe8afed1685e54017fb81cea898867 (patch)
tree0e0905a1fd74b77ffb7dfaae7f182222acd5fca1 /ext/json/parser
parent932762f29457ad1def6fbab7eca7bcbeeb58ea5c (diff)
[ruby/json] Fix a regression in parsing of unicode surogate pairs
Fix: https://github.com/ruby/json/issues/912 In the case of surogate pairs we consume two backslashes, so `json_next_backslash` need to ensure it's not sending us back in the stream. https://github.com/ruby/json/commit/0fce370c41
Diffstat (limited to 'ext/json/parser')
-rw-r--r--ext/json/parser/parser.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c
index 5b7cd835cd..c84c7ed660 100644
--- a/ext/json/parser/parser.c
+++ b/ext/json/parser/parser.c
@@ -651,7 +651,9 @@ static inline const char *json_next_backslash(const char *pe, const char *string
positions->size--;
const char *next_position = positions->positions[0];
positions->positions++;
- return next_position;
+ if (next_position >= pe) {
+ return next_position;
+ }
}
if (positions->has_more) {