Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [bug] busy loop and memory exhaustion on {x..$'\80'} with nomultibyte
> 2022/09/23 19:54, Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
>
> $ (limit cputime 10; TIMEFMT='%MMiB %U user %S sys'; time zsh +o multibyte -c ": {z..$'\x80'}")
> 3980MiB 8.84s user 1.40s sys
>
> {$'\x80'..$'\xff} doesn't have the problem, but the expansion is:
(snip)
> With {$'\x80'..$'\xff'}, we get:
>
> $ zsh +o multibyte -c "printf %s {$'\x80'..$'\xff'}" | hd
> 00000000 7b 80 2e 2e ff 7d |{....}|
Does this solve the problem?
diff --git a/Src/utils.c b/Src/utils.c
index 62bd3e602..edf5d3df7 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5519,7 +5519,7 @@ mb_metacharlenconv(const char *s, wint_t *wcp)
if (!isset(MULTIBYTE) || STOUC(*s) <= 0x7f) {
/* treat as single byte, possibly metafied */
if (wcp)
- *wcp = (wint_t)(*s == Meta ? s[1] ^ 32 : *s);
+ *wcp = (wint_t)STOUC(*s == Meta ? s[1] ^ 32 : *s);
return 1 + (*s == Meta);
}
/*
Messages sorted by:
Reverse Date,
Date,
Thread,
Author