diff options
Diffstat (limited to 'src/interfaces')
| -rw-r--r-- | src/interfaces/libpq/fe-exec.c | 6 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-misc.c | 15 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 73c3a0f9025..350a33f431c 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -4003,7 +4003,8 @@ PQescapeStringInternal(PGconn *conn, } /* Slow path for possible multibyte characters */ - charlen = pg_encoding_mblen(encoding, source); + charlen = pg_encoding_mblen_or_incomplete(encoding, + source, remaining); if (remaining < charlen || pg_encoding_verifymbchar(encoding, source, charlen) == -1) @@ -4149,7 +4150,8 @@ PQescapeInternal(PGconn *conn, const char *str, size_t len, bool as_ident) int charlen; /* Slow path for possible multibyte characters */ - charlen = pg_encoding_mblen(conn->client_encoding, s); + charlen = pg_encoding_mblen_or_incomplete(conn->client_encoding, + s, remaining); if (charlen > remaining) { diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 128f056825d..b8e3ace7483 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -1173,13 +1173,9 @@ pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time) */ /* - * Returns the byte length of the character beginning at s, using the - * specified encoding. - * - * Caution: when dealing with text that is not certainly valid in the - * specified encoding, the result may exceed the actual remaining - * string length. Callers that are not prepared to deal with that - * should use PQmblenBounded() instead. + * Like pg_encoding_mblen(). Use this in callers that want the + * dynamically-linked libpq's stance on encodings, even if that means + * different behavior in different startups of the executable. */ int PQmblen(const char *s, int encoding) @@ -1188,8 +1184,9 @@ PQmblen(const char *s, int encoding) } /* - * Returns the byte length of the character beginning at s, using the - * specified encoding; but not more than the distance to end of string. + * Like pg_encoding_mblen_bounded(). Use this in callers that want the + * dynamically-linked libpq's stance on encodings, even if that means + * different behavior in different startups of the executable. */ int PQmblenBounded(const char *s, int encoding) |
