Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Fix handling of NUL bytes in zexpandtabs multibyte version
- X-seq: zsh-workers 48168
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: Fix handling of NUL bytes in zexpandtabs multibyte version
- Date: Fri, 12 Mar 2021 03:51:22 +0100
- Archived-at: <https://zsh.org/workers/48168>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-03/20210312025122.23804-1-mikachu%40gmail.com>
- List-id: <zsh-workers.zsh.org>
Problem found by dg1727 on #zsh.
---
I checked other uses of zexpandtabs in the same file only and they all
seem to handle the 0 return correctly, and some of them even comment on
it, so fairly confident this is the right fix.
---
Src/utils.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Src/utils.c b/Src/utils.c
index 8fcea5362a..f8cbe65ba5 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5936,8 +5936,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 {
--
2.15.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author