Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: crash in completing code with unicode support



On Tuesday 16 August 2005 16:01, Mikael Magnusson wrote:
>
> mkdir /tmp/foo
> cd /tmp/foo
> a=`echo +ANg- | iconv -f utf-7 -t utf-8`
> touch ${a}a ${a}b
> zsh -f
> autoload -U compinit; compinit
> ls <tab><tab>
>
> That is all i have to do to get the crash. (I didn't compile with
> --enable-zsh-debug, because then i only get an error message like
> "BUG: substring ends in the middle of a metachar in ztrsub()", instead
> i specified the flags manually)

I still cannot make it crash but I get BUG in ztrsub too.

The bug was always there it is just that it is much more difficult to create 
such case in single byte encoding. Does the following patch helps? (somewhat 
unexpectedly all regression tests still pass here)

Index: complete.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complete.c,v
retrieving revision 1.28
diff -u -p -r1.28 complete.c
--- complete.c  21 Mar 2005 18:49:41 -0000      1.28
+++ complete.c  16 Aug 2005 19:24:00 -0000
@@ -821,8 +821,9 @@ do_comp_vars(int test, int na, char *sa,
                    add = -1;
                } else {
                    p = compprefix + 1;
+                   /* FIXME check EOS */
                    if (*p == Meta)
-                       p++;
+                       p += 2;
                    add = 1;
                }
                for (;;) {
@@ -835,6 +836,7 @@ do_comp_vars(int test, int na, char *sa,
                    if (add > 0) {
                        if (p == compprefix + l)
                            return 0;
+                       /* FIXME check EOS */
                        if (*p == Meta)
                            p += 2;
                        else

Attachment: pgpATUn66uuO5.pgp
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author