fix(fileio): replace characters over INT_MAX with U+FFFD (#16354)

fixes #11877
credit: @zubairabid https://github.com/neovim/neovim/pull/12010
This commit is contained in:
Javier Lopez
2021-11-23 23:07:47 -05:00
committed by GitHub
parent dd8a4e2c22
commit a2e5c2f7c8
2 changed files with 13 additions and 0 deletions

View File

@@ -1360,6 +1360,10 @@ retry:
u8c += (unsigned)(*--p) << 16;
u8c += (unsigned)(*--p) << 24;
}
// Replace characters over INT_MAX with Unicode replacement character
if (u8c > INT_MAX) {
u8c = 0xfffd;
}
} else { // UTF-8
if (*--p < 0x80) {
u8c = *p;