summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuo Ishii2012-12-02 12:11:15 +0000
committerTatsuo Ishii2012-12-02 12:22:54 +0000
commitcd99d20550a36c673cc5003c7987f816d6cd3eb3 (patch)
tree9d9c2953f8c7e4fa8778573975a53b5245faf8a0 /src
parentb4cad625113e42bd8c9c3bad8390ebbdb60b3aad (diff)
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 b8b5240d64a..cb90fa70c56 100644
--- a/src/bin/psql/psqlscan.l
+++ b/src/bin/psql/psqlscan.l
@@ -1702,7 +1702,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;
}
}