From ea3351c49610355512672ab478c715ba3cb92aef Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Fri, 12 Mar 2021 03:50:01 +0100 Subject: 48202 + 48366: Fix handling of NUL bytes in zexpandtabs multibyte version --- Src/utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Src/utils.c') diff --git a/Src/utils.c b/Src/utils.c index 2a8d677a7..1ac064a4e 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -5912,8 +5912,11 @@ zexpandtabs(const char *s, int len, int width, int startpos, FILE *fout, memset(&mbs, 0, sizeof(mbs)); s++; len--; - } else if (ret == MB_INCOMPLETE) { + } else if (ret == MB_INCOMPLETE || /* incomplete at end --- assume likewise, best we've got */ + ret == 0) { + /* NUL character returns 0, which would loop infinitely, so advance + * one byte in this case too */ s++; len--; } else { -- cgit 1.4.1