From: Zefram <A.Main@dcs.warwick.ac.uk>
To: zsh-workers@math.gatech.edu (Z Shell workers mailing list)
Subject: clwords bugfix
Date: Sat, 25 May 1996 15:38:51 +0100 (BST) [thread overview]
Message-ID: <27894.199605251438@stone.dcs.warwick.ac.uk> (raw)
-----BEGIN PGP SIGNED MESSAGE-----
There is a bug in zle_tricky.c (ooh, what a surprise). When the
clwords array needs to be resized, the new part of the array is
supposed to be initialised to NULLs. The current version has
an off-by-one error, meaning that it clears the current element
(which is immediately freed, so there is only a memory leak here),
but it doesn't clear the new last element (this causes crashes).
The patch below fixes this, and changes it to use a looped assignment
rather than memset, as NULL is not all-bits-zero on all machines.
-zefram
Index: Src/zle_tricky.c
*** zle_tricky.c 1996/05/25 13:14:10 1.22
--- zle_tricky.c 1996/05/25 13:33:10
***************
*** 998,1006 ****
* more complicated compctl -x things). They are stored in the *
* clwords array. Make this array big enough. */
if (i + 1 == clwsize) {
clwords = (char **)realloc(clwords,
(clwsize *= 2) * sizeof(char *));
! memset((void *) (clwords + i), 0, (clwsize / 2) * sizeof(char *));
}
zsfree(clwords[i]);
/* And store the current token string. */
--- 998,1008 ----
* more complicated compctl -x things). They are stored in the *
* clwords array. Make this array big enough. */
if (i + 1 == clwsize) {
+ int n;
clwords = (char **)realloc(clwords,
(clwsize *= 2) * sizeof(char *));
! for(n = clwsize; --n > i; )
! clwords[n] = NULL;
}
zsfree(clwords[i]);
/* And store the current token string. */
-----BEGIN PGP SIGNATURE-----
Version: 2.6.i
iQCVAgUBMacbanD/+HJTpU/hAQFLBwP/Ygx3Hr5KQFL0cGSoi7GAHWMp1yZxgC3B
jILcjEo6Wp+LJPcwA+vqmRrPIUad7SYIWzzi+9h46VcedepDuG/aIYpvEojYBOFr
MDBsKmJD9HBONKStYYfNc6+ruuMS2pw1mW1Kv9fJTtBzMo1zOFpfkQvaS5OtzFtd
u+Zxabwl3Z4=
=k2tq
-----END PGP SIGNATURE-----
next reply other threads:[~1996-05-25 15:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-05-25 14:38 Zefram [this message]
1996-05-25 18:02 ` Richard Coleman
1996-05-25 20:52 ` Zefram
1996-05-25 21:25 ` (NULL == 0) ? Richard Coleman
1996-05-25 22:00 ` Zefram
1996-05-27 0:00 ` Zoltan Hidvegi
1996-05-27 6:39 ` Bart Schaefer
1996-05-27 7:29 ` anthony baxter
1996-05-27 13:07 ` Zefram
1996-05-27 22:00 ` Zoltan Hidvegi
1996-05-27 22:11 ` Zefram
1996-05-27 22:41 ` Zoltan Hidvegi
1996-05-27 22:54 ` Zefram
1996-05-28 4:54 ` Bart Schaefer
1996-05-27 23:36 ` Bart Schaefer
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=27894.199605251438@stone.dcs.warwick.ac.uk \
--to=a.main@dcs.warwick.ac.uk \
--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).