Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH 15/17: Don't leak ifs stuff



On Tue, 6 Jan 2015 06:25:47 +0100
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> Found by Coverity (Issue 1255785).
> ---
>  Src/utils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Src/utils.c b/Src/utils.c
> index 390f513..72a0c9c 100644
> --- a/Src/utils.c
> +++ b/Src/utils.c
> @@ -3543,7 +3543,7 @@ inittyptab(void)
>      for (t0 = (int)STOUC(Snull); t0 <= (int)STOUC(Nularg); t0++)
>  	typtab[t0] |= ITOK | IMETA | INULL;
>      for (s = ifs ? ifs : EMULATION(EMULATE_KSH|EMULATE_SH) ?
> -	ztrdup(DEFAULT_IFS_SH) : ztrdup(DEFAULT_IFS); *s; s++) {
> +	DEFAULT_IFS_SH : DEFAULT_IFS; *s; s++) {
>  	int c = STOUC(*s == Meta ? *++s ^ 32 : *s);
>  #ifdef MULTIBYTE_SUPPORT
>  	if (!isascii(c)) {
> @@ -3578,7 +3578,7 @@ inittyptab(void)
>  #ifdef MULTIBYTE_SUPPORT
>      set_widearray(wordchars, &wordchars_wide);
>      set_widearray(ifs ? ifs : EMULATION(EMULATE_KSH|EMULATE_SH) ?
> -	ztrdup(DEFAULT_IFS_SH) : ztrdup(DEFAULT_IFS), &ifs_wide);
> +	DEFAULT_IFS_SH : DEFAULT_IFS, &ifs_wide);
>  #endif
>      for (s = SPECCHARS; *s; s++)
>  	typtab[STOUC(*s)] |= ISPECIAL;

That looks OK.

ifs gets initialised in that way during setupvals().  I guess the code
in inittyptab() just got copied from there when someone spotted it could
happen before setupvals() ran, and the code didn't get properly edited
when copied.

pws



Messages sorted by: Reverse Date, Date, Thread, Author