From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: Fix handling of NUL bytes in zexpandtabs multibyte version
Date: Fri, 12 Mar 2021 03:51:22 +0100 [thread overview]
Message-ID: <20210312025122.23804-1-mikachu@gmail.com> (raw)
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
next reply other threads:[~2021-03-12 2:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-12 2:51 Mikael Magnusson [this message]
2021-03-12 3:17 ` Mikael Magnusson
2021-03-12 13:53 ` Daniel Shahaf
2021-03-20 1:22 ` Lawrence Velázquez
2021-03-20 15:15 ` PATCH v2: 48168: " Mikael Magnusson
2021-03-27 16:11 ` Lawrence Velázquez
2021-04-01 5:21 ` Jun T
2021-04-01 7:46 ` Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210312025122.23804-1-mikachu@gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).