Skip to content

Commit a7c5309

Browse files
committed
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.
1 parent 647b1bc commit a7c5309

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/bin/psql/psqlscan.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ prepare_buffer(const char *txt, int len, char **txtcopy)
18031803
/* first byte should always be okay... */
18041804
newtxt[i] = txt[i];
18051805
i++;
1806-
while (--thislen > 0)
1806+
while (--thislen > 0 && i < len)
18071807
newtxt[i++] = (char) 0xFF;
18081808
}
18091809
}

0 commit comments

Comments
 (0)