From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5245 invoked from network); 17 Mar 1997 18:28:35 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 17 Mar 1997 18:28:35 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id NAA00502; Mon, 17 Mar 1997 13:16:13 -0500 (EST) Resent-Date: Mon, 17 Mar 1997 13:16:13 -0500 (EST) Date: Mon, 17 Mar 1997 18:18:51 GMT From: Zefram Message-Id: <5269.199703171818@stone.dcs.warwick.ac.uk> Subject: Re: 3 bugs for zsh3.0.0 X-Patch: 205 Resent-Message-ID: <"L6Fhv.0.k7.ifOBp"@euclid> To: zsh-workers@math.gatech.edu Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2998 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- >2) bus error on: >local undefined >echo ${undefined#crap} The parameter code, when asked for the value of an undefined parameter, is returning a constant empty string. The glob code assumes that it can write into any parameter value. The real solution would be to stop the glob code writing into strings that it shouldn't modify, and I'd like to do this as part of making zsh const-correct. But for the moment it will suffice to make the parameter code return an allocated empty string, as it already does in some cases. -zefram *** Src/params.c 1997/03/17 00:38:10 1.36 --- Src/params.c 1997/03/17 13:16:13 *************** *** 677,685 **** char *s, **ss; static char buf[(SIZEOF_LONG * 8) + 4]; - if (!v) - return ""; HEAPALLOC { if (v->inv) { sprintf(buf, "%d", v->a); s = dupstring(buf); --- 677,685 ---- char *s, **ss; static char buf[(SIZEOF_LONG * 8) + 4]; HEAPALLOC { + if (!v) + return dupstring(""); if (v->inv) { sprintf(buf, "%d", v->a); s = dupstring(buf); *************** *** 694,700 **** ss = v->pm->gets.afn(v->pm); if (v->a < 0) v->a += arrlen(ss); ! s = (v->a >= arrlen(ss) || v->a < 0) ? "" : ss[v->a]; } LASTALLOC_RETURN s; case PM_INTEGER: --- 694,700 ---- ss = v->pm->gets.afn(v->pm); if (v->a < 0) v->a += arrlen(ss); ! s = (v->a >= arrlen(ss) || v->a < 0) ? dupstring("") : ss[v->a]; } LASTALLOC_RETURN s; case PM_INTEGER: *************** *** 1188,1194 **** char * strgetfn(Param pm) { ! return pm->u.str ? pm->u.str : ""; } /* Function to set value of a scalar (string) parameter */ --- 1188,1194 ---- char * strgetfn(Param pm) { ! return pm->u.str ? pm->u.str : hcalloc(1); } /* Function to set value of a scalar (string) parameter */ *************** *** 1314,1320 **** char *s = *((char **)pm->data); if (!s) ! return ""; return s; } --- 1314,1320 ---- char *s = *((char **)pm->data); if (!s) ! return hcalloc(1); return s; } -----BEGIN PGP SIGNATURE----- Version: 2.6.3ia Charset: ascii iQCVAwUBMy1FZXD/+HJTpU/hAQE5kQP/aYmYQVr7bUhFhdjissNyzeFn1Bb6DpYG Hs7X+VpQut8RkqoKXhe9Dqy3DW2xr1DhW9anNhOHkYf5Aqo0KhlNuB1stPrpi/tT 4pLIjxZUuGhQv3XShafyaxJoxGwWSnfXgBNa47zNVvsJAfMGs7UD+FR0KBAc7PXl uPehnmaqnHg= =ooJu -----END PGP SIGNATURE-----