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

Re: crash in completing code with unicode support



On Wednesday 17 August 2005 01:49, Wayne Davison wrote:
> On Tue, Aug 16, 2005 at 02:37:13PM -0700, Wayne Davison wrote:
> > If the above is right, then this line should probably be changed to be:
> >
> >     if (p == compprefix + l + (*compprefix == Meta))
>

Of course I went blind.

The patch adds check for EOS, it intentionally leaves pointer at the end to 
let ztrsub() complaint later.

Index: Src/Zle/complete.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complete.c,v
retrieving revision 1.29
diff -u -p -r1.29 complete.c
--- Src/Zle/complete.c  16 Aug 2005 21:49:33 -0000      1.29
+++ Src/Zle/complete.c  18 Aug 2005 16:30:36 -0000
@@ -821,6 +821,8 @@ do_comp_vars(int test, int na, char *sa,
                    add = -1;
                } else {
                    p = compprefix + 1 + (*compprefix == Meta);
+                   if (p > compprefix + l)
+                       p = compprefix + l;
                    add = 1;
                }
                for (;;) {
@@ -833,10 +835,9 @@ do_comp_vars(int test, int na, char *sa,
                    if (add > 0) {
                        if (p == compprefix + l)
                            return 0;
-                       if (*p == Meta)
-                           p += 2;
-                       else
-                           p++;
+                       p = p + 1 + (*p == Meta);
+                       if (p > compprefix + l)
+                           p = compprefix + l;
                    } else {
                        if (p == compprefix)
                            return 0;


Attachment: pgpipoXs8GCMa.pgp
Description: PGP signature



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