From: pws@ifh.de (Peter William Stephenson)
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Bad frees in bindkey code
Date: Tue, 17 Oct 1995 09:57:39 +0100 (MET) [thread overview]
Message-ID: <9510170857.AA18412@sgi.ifh.de> (raw)
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.
reply other threads:[~1995-10-17 9:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9510170857.AA18412@sgi.ifh.de \
--to=pws@ifh.de \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).