zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: 3.1.6-pws-6: $compstate[unambiguous] could be garbage
@ 1999-10-07 10:40 Bart Schaefer
  1999-10-07 17:30 ` Clint Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 1999-10-07 10:40 UTC (permalink / raw)
  To: zsh-workers

Earlier today I started noticing

_main_complete: 95: bad set of key/value pairs for associative array

Line 95 is copying the entire $compstate assoc int $lastcomp.  I eventually
tracked the problem to the value of `unambiguous' which it seemed was being
dropped from the ${(@kv)compstate} expansion.  Turns out the reason it was
being dropped is that it pointed to a garbage string because unambig_data()
was being called twice and was freeing and reallocating the cached value
each time; the string returned the first time ended up pointing into free
memory.

I don't know whether the `|| !ainfo' is necessary in the patch below, but
it seemed safest to have it there.  It was always nonzero in the bug case,
but I didn't go through every possible call to the function.

Index: Src/Zle/zle_tricky.c
===================================================================
@@ -7963,7 +7963,7 @@
 	    scache = cline_str((ainfo->count ? ainfo->line : fainfo->line),
 			       0, &ccache);
 	}
-    } else {
+    } else if (mnum != unambig_mnum || !ainfo || !scache) {
 	zsfree(scache);
 	scache = ztrdup("");
 	ccache = 0;

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

end of thread, other threads:[~1999-10-08  7:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-07 10:40 PATCH: 3.1.6-pws-6: $compstate[unambiguous] could be garbage Bart Schaefer
1999-10-07 17:30 ` Clint Adams
1999-10-07 21:36   ` Bart Schaefer
1999-10-08  7:46     ` Clint Adams

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