aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2012-12-02 21:11:15 +0900
committerTatsuo Ishii <ishii@postgresql.org>2012-12-02 21:21:01 +0900
commit530cbf6b10af156276d45687d14ca05cd4e39d16 (patch)
tree9a33542212f7404a5720c990f6cfad0e9ba9e83c
parent19a08ef7d3a8cd8327289c2183f8402d6b7dade9 (diff)
downloadpostgresql-530cbf6b10af156276d45687d14ca05cd4e39d16.tar.gz
postgresql-530cbf6b10af156276d45687d14ca05cd4e39d16.zip
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.
-rw-r--r--src/bin/psql/psqlscan.l2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/bin/psql/psqlscan.l b/src/bin/psql/psqlscan.l
index 1208c8f475c..a3d569f13db 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;
}
}