aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/jsonapi.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/common/jsonapi.c b/src/common/jsonapi.c
index ca4bb57b9d7..2da0be0ee91 100644
--- a/src/common/jsonapi.c
+++ b/src/common/jsonapi.c
@@ -680,6 +680,7 @@ static inline JsonParseErrorType
json_lex_string(JsonLexContext *lex)
{
char *s;
+ char *const end = lex->input + lex->input_length;
int len;
int hi_surrogate = -1;
@@ -691,8 +692,8 @@ json_lex_string(JsonLexContext *lex)
} while (0)
#define FAIL_AT_CHAR_END(code) \
do { \
- lex->token_terminator = \
- s + pg_encoding_mblen_bounded(lex->input_encoding, s); \
+ char *term = s + pg_encoding_mblen(lex->input_encoding, s); \
+ lex->token_terminator = (term <= end) ? term : end; \
return code; \
} while (0)