aboutsummaryrefslogtreecommitdiff
path: root/src
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:11:15 +0900
commit53edb8dc0274e0d05eb0371ce84b7fb14cb5eb5a (patch)
treec68b24694acb1857c482f346e615dbb483b12f30 /src
parentc35fea102628fedf9e62c6a440073257676a873b (diff)
downloadpostgresql-53edb8dc0274e0d05eb0371ce84b7fb14cb5eb5a.tar.gz
postgresql-53edb8dc0274e0d05eb0371ce84b7fb14cb5eb5a.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.
Diffstat (limited to 'src')
-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 d32a12c63c8..6c1429815f2 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;
}
}