From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id BAA05696 for ; Sun, 26 May 1996 01:19:37 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id LAA04996; Sat, 25 May 1996 11:09:06 -0400 (EDT) Resent-Date: Sat, 25 May 1996 11:09:06 -0400 (EDT) From: Zefram Message-Id: <27894.199605251438@stone.dcs.warwick.ac.uk> Subject: clwords bugfix To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Sat, 25 May 1996 15:38:51 +0100 (BST) X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]7558.05 X-US-Congress: Moronic fuckers MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"oNcvX3.0.-D1.IAofn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1173 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----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-----