From: Tatsuo Ishii Date: Sun, 2 Dec 2012 12:11:15 +0000 (+0900) Subject: Fix psql crash while parsing SQL file whose encoding is different from X-Git-Tag: REL9_2_2~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=530cbf6b10af156276d45687d14ca05cd4e39d16;p=postgresql Fix psql crash while parsing SQL file whose encoding is different from client encoding and the client encoding is not *safe* one. Such an example is, file encoding is UTF-8 and client encoding SJIS. Patch contributed by Jiang Guiqing. --- diff --git a/src/bin/psql/psqlscan.l b/src/bin/psql/psqlscan.l index 1208c8f475..a3d569f13d 100644 --- a/src/bin/psql/psqlscan.l +++ b/src/bin/psql/psqlscan.l @@ -1807,7 +1807,7 @@ prepare_buffer(const char *txt, int len, char **txtcopy) /* first byte should always be okay... */ newtxt[i] = txt[i]; i++; - while (--thislen > 0) + while (--thislen > 0 && i < len) newtxt[i++] = (char) 0xFF; } }