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

Re: odd completion behavior



Bart Schaefer wrote:

> If I had to guess, I'd say that the stack is getting trashed because
> the VARARR() at exec.c:3019 is not allocating the right number of bytes.

I suspected the VARARR()s, too, but...

> That wouldn't show up in any of the zsh memory testing stuff because it
> is using alloca() or the equivalent to create space on the stack, and
> it would explain how the bogus frame #8 got stuck in there.
> 
> Could the global underscorelen be messed up at that point?

for this one there was only a small chance with a combination of
checkmailpath() being invoked and a mail prompt that needed to be
singsub()ed, I think.

And now that I looked again, I saw that the one in `complist' may be
wrong allocated with the wrong size. This could only cause problems if 
menu-selection was used and none of the `ZLS_*' parameters was
set. (Btw., Clint, does it complete something after the
`--pretty-print=' or are there no possible completions?)

All other VARARR()s look OK, as far as I can tell.


If only we knew at which version this started to misbehave...


Bye
 Sven

diff -u os/utils.c Src/utils.c
--- os/utils.c	Mon Sep 20 13:06:20 1999
+++ Src/utils.c	Mon Sep 20 13:17:08 1999
@@ -752,9 +752,14 @@
 		    fprintf(shout, "You have new mail.\n");
 		    fflush(shout);
 		} else {
-		    char *usav = underscore;
+		    VARARR(char, usav, underscorelen);
+		    int sl = strlen(*s);
 
-		    underscore = *s;
+		    if (sl >= underscorelen) {
+			zfree(underscore, underscorelen);
+			underscore = (char *) zalloc(underscorelen = sl + 32);
+		    }
+		    strcpy(underscore, *s);
 		    HEAPALLOC {
 			u = dupstring(u);
 			if (! parsestr(u)) {
@@ -763,8 +768,8 @@
 			    fputc('\n', shout);
 			    fflush(shout);
 			}
-			underscore = usav;
 		    } LASTALLOC;
+		    strcpy(underscore, usav);
 		}
 	    }
 	    if (isset(MAILWARNING) && st.st_atime > st.st_mtime &&
diff -u os/Zle/complist.c Src/Zle/complist.c
--- os/Zle/complist.c	Mon Sep 20 13:06:26 1999
+++ Src/Zle/complist.c	Mon Sep 20 13:25:49 1999
@@ -217,6 +217,10 @@
 	    c->cols[COL_MA] = "";
 	else
 	    c->cols[COL_EC] = tcstr[TCSTANDOUTEND];
+	lr_caplen = 0;
+	if ((max_caplen = strlen(c->cols[COL_MA])) <
+	    (l = strlen(c->cols[COL_EC])))
+	    max_caplen = l;
 	return;
     }
     /* We have one of the parameters, use it. */
@@ -230,7 +234,7 @@
     for (i = 0; i < NUM_COLS; i++) {
 	if (!c->cols[i])
 	    c->cols[i] = defcols[i];
-	if ((l = (c->cols[i] ? strlen(c->cols[i]) : 0)) > max_caplen)
+	if (c->cols[i] && (l = strlen(c->cols[i])) > max_caplen)
 	    max_caplen = l;
     }
     lr_caplen = strlen(c->cols[COL_LC]) + strlen(c->cols[COL_RC]);

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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