zsh-workers
 help / color / mirror / code / Atom feed
* Bad frees in bindkey code
@ 1995-10-17  8:57 Peter William Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter William Stephenson @ 1995-10-17  8:57 UTC (permalink / raw)
  To: Zsh hackers list

I've been getting some messages about freeing already free storage
from bindkey's with multiple lead-in characters, which this purports
to fix.   I think I've found all the places a key's str component is
freed and set it to zero.  (I could have checked for z_sendstring at
the second free instead, but it seems neater to make sure the pointer
is null anyway.)

(And greetings from eastern Germany, too.)

*** Src/zle_main.c.free	Tue Oct 10 01:26:42 1995
--- Src/zle_main.c	Tue Oct 17 09:44:34 1995
***************
*** 924,931 ****
  			free(keybindtab->removenode(keybindtab, s));
  		} else {
  		    if (ky && ky->prefixct) {
! 			if (ky->func == z_sendstring)
  			    zfree(ky->str, ky->len);
  			ky->func = z_undefinedkey;
  		    } else
  			free(keybindtab->removenode(keybindtab, s));
--- 924,933 ----
  			free(keybindtab->removenode(keybindtab, s));
  		} else {
  		    if (ky && ky->prefixct) {
! 			if (ky->func == z_sendstring) {
  			    zfree(ky->str, ky->len);
+ 			    ky->str = NULL;
+ 			}
  			ky->func = z_undefinedkey;
  		    } else
  			free(keybindtab->removenode(keybindtab, s));
***************
*** 995,1002 ****
  			*s = (char)0x80;
  		}
  	    if (cur) {
  		cur->func = func;
- 		zfree(cur->str, cur->len);
  	    } else
  		keybindtab->addnode(keybindtab, ztrdup(s), cur = makefunckey(func));
  	    if (firstzero)
--- 997,1007 ----
  			*s = (char)0x80;
  		}
  	    if (cur) {
+ 		if (cur->str) {
+ 		    zfree(cur->str, cur->len);
+ 		    cur->str = NULL;
+ 		}
  		cur->func = func;
  	    } else
  		keybindtab->addnode(keybindtab, ztrdup(s), cur = makefunckey(func));
  	    if (firstzero)

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-10-17  9:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-10-17  8:57 Bad frees in bindkey code Peter William 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).