Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 53edb8d

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 c35fea1 commit 53edb8d

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
@@ -1807,7 +1807,7 @@ prepare_buffer(const char *txt, int len, char **txtcopy)
18071807
/* first byte should always be okay... */
18081808
newtxt[i] = txt[i];
18091809
i++;
1810-
while (--thislen > 0)
1810+
while (--thislen > 0 && i < len)
18111811
newtxt[i++] = (char) 0xFF;
18121812
}
18131813
}

0 commit comments

Comments
 (0)