From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gatech.edu (gatech.edu [130.207.244.244]) by werple.net.au (8.7/8.7) with SMTP id TAA08912 for ; Tue, 17 Oct 1995 19:00:07 +1000 (EST) Received: from euclid (euclid.skiles.gatech.edu) by gatech.edu with SMTP id AA14049 (5.65c/Gatech-10.0-IDA for ); Tue, 17 Oct 1995 04:58:28 -0400 Received: by euclid (5.x/SMI-SVR4) id AA10242; Tue, 17 Oct 1995 04:56:52 -0400 Resent-Date: Tue, 17 Oct 1995 09:57:39 +0100 (MET) Old-Return-Path: From: pws@ifh.de (Peter William Stephenson) Message-Id: <9510170857.AA18412@sgi.ifh.de> Subject: Bad frees in bindkey code To: zsh-workers@math.gatech.edu (Zsh hackers list) Date: Tue, 17 Oct 1995 09:57:39 +0100 (MET) X-Mailer: ELM [version 2.4 PL24] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-Id: <"Fvkp01.0.yV2.J_sWm"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/460 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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 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.