zsh-workers
 help / color / mirror / code / Atom feed
* Infinite loop in compprintfmt() (complist.c rev 1.91)
@ 2006-08-14  4:48 Bart Schaefer
  2006-08-14 12:52 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2006-08-14  4:48 UTC (permalink / raw)
  To: zsh-workers

Here's a gdb walk-through -- note we return to line 896 (really the loop
at 892) without ever incrementing the loop variable.

892         for (p = fmt; *p; ) {
893             convchar_t cchar;
894             int len, width;
(gdb) n
896             len = MB_METACHARLENCONV(p, &cchar);
(gdb) n
898             if (cchar == WEOF) {
(gdb) n
904                 width = WCWIDTH(cchar);
(gdb) n
906             if (doesc && cchar == ZWC('%')) {
(gdb) n
1043                cc += width;
(gdb) n
1045                if ((cc >= columns - 2 || cchar == ZWC('\n')) && stat)
(gdb) n
1047                if (cchar == ZWC('\n')) {
(gdb) n
1053                if (dopr == 1) {
(gdb) n
896             len = MB_METACHARLENCONV(p, &cchar);

The call is from line 1557, dopr = 0:

1554            if (subcols)
1555                ret = clprintfmt(&mcolors, m->disp, ml);
1556            else {
1557                compprintfmt(m->disp, 0, 1, 0, ml, &stop);
1558                if (stop)
1559                    ret = 1;
1560            }

I was only able to get the loop to happen by accident -- something having
to do with invoking execute-named-command in the middle of menu-selection.
So I'm not able to reproduce it, and don't know if the right thing is to
simply increment p when dopr != 1 ?  PWS, gotta clue?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Infinite loop in compprintfmt() (complist.c rev 1.91)
  2006-08-14  4:48 Infinite loop in compprintfmt() (complist.c rev 1.91) Bart Schaefer
@ 2006-08-14 12:52 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2006-08-14 12:52 UTC (permalink / raw)
  To: Zsh hackers list

Bart Schaefer <schaefer@brasslantern.com> wrote:
> Here's a gdb walk-through -- note we return to line 896 (really the loop
> at 892) without ever incrementing the loop variable.

Yes, I missed the dopr==0 branch when I moved the increment into the point
where we're possibly printing more than one byte.

Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.91
diff -u -r1.91 complist.c
--- Src/Zle/complist.c	11 Aug 2006 21:30:38 -0000	1.91
+++ Src/Zle/complist.c	14 Aug 2006 12:50:29 -0000
@@ -1069,6 +1069,8 @@
 		    return mlprinted;
 		}
 	    }
+	    else
+		p += len;
 	}
     }
     if (dopr) {

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-08-14 12:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-14  4:48 Infinite loop in compprintfmt() (complist.c rev 1.91) Bart Schaefer
2006-08-14 12:52 ` Peter Stephenson

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).