diff options
Diffstat (limited to 'src/common/jsonapi.c')
-rw-r--r-- | src/common/jsonapi.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/common/jsonapi.c b/src/common/jsonapi.c index 8da2bdb271b..573375618d7 100644 --- a/src/common/jsonapi.c +++ b/src/common/jsonapi.c @@ -700,8 +700,11 @@ json_lex_string(JsonLexContext *lex) } while (0) #define FAIL_AT_CHAR_END(code) \ do { \ - char *term = s + pg_encoding_mblen(lex->input_encoding, s); \ - lex->token_terminator = (term <= end) ? term : end; \ + ptrdiff_t remaining = end - s; \ + int charlen; \ + charlen = pg_encoding_mblen_or_incomplete(lex->input_encoding, \ + s, remaining); \ + lex->token_terminator = (charlen <= remaining) ? s + charlen : end; \ return code; \ } while (0) |