From a2e5c2f7c8ec2b236a0c33cf9fc3cbab17c6cfcd Mon Sep 17 00:00:00 2001 From: Javier Lopez Date: Tue, 23 Nov 2021 23:07:47 -0500 Subject: fix(fileio): replace characters over INT_MAX with U+FFFD (#16354) fixes #11877 credit: @zubairabid https://github.com/neovim/neovim/pull/12010 --- src/nvim/fileio.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 7573064fa9..1b39a7410a 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -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; -- cgit