* hang in brace expansion
@ 2014-08-20 21:37 Mikael Magnusson
2014-08-20 22:08 ` PATCH: Fix {^@..a} hanging Mikael Magnusson
0 siblings, 1 reply; 2+ messages in thread
From: Mikael Magnusson @ 2014-08-20 21:37 UTC (permalink / raw)
To: zsh workers
Doing {^@..a} will hang indefinitely (where ^@ is a literal null
character). The problem is in xpandbraces in glob.c,
for (; cend >= cstart; cend--) {
cend and cstart are unsigned types and cstart is 0. I'm a bit tired at
the moment so I can't figure out a nice way to write this loop that
always works. The value cend is used inside the loop, cstart isn't. I
suppose we could just add if (cend == 0) break; at the last line of
the loop?
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 2+ messages in thread
* PATCH: Fix {^@..a} hanging
2014-08-20 21:37 hang in brace expansion Mikael Magnusson
@ 2014-08-20 22:08 ` Mikael Magnusson
0 siblings, 0 replies; 2+ messages in thread
From: Mikael Magnusson @ 2014-08-20 22:08 UTC (permalink / raw)
To: zsh-workers
This should work for all possible cases, and is fine since we always
want to enter the loop at least once anyway.
---
Src/glob.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Src/glob.c b/Src/glob.c
index 3bf66e4..bf758d4 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2228,7 +2228,7 @@ xpandbraces(LinkList list, LinkNode *np)
uremnode(list, node);
strp = str - str3;
lenalloc = strp + strlen(str2+1) + 1;
- for (; cend >= cstart; cend--) {
+ do {
#ifdef MULTIBYTE_SUPPORT
char *ncptr;
int nclen;
@@ -2248,7 +2248,7 @@ xpandbraces(LinkList list, LinkNode *np)
insertlinknode(list, last, p);
if (rev) /* decreasing: add in reverse order. */
last = nextnode(last);
- }
+ } while (cend-- > cstart);
*np = nextnode(olast);
return;
}
--
1.9.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-20 23:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-20 21:37 hang in brace expansion Mikael Magnusson
2014-08-20 22:08 ` PATCH: Fix {^@..a} hanging Mikael Magnusson
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).