Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: zsh-3.1.5-pws-4 + typeset fix: memory leak
- X-seq: zsh-workers 4920
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxxxxxxxxxx
- Subject: Re: PATCH: zsh-3.1.5-pws-4 + typeset fix: memory leak
- Date: Fri, 15 Jan 1999 08:43:15 -0800
- In-reply-to: <9901151544.AA14645@xxxxxxxxxxxxxxxxx>
- References: <9901151544.AA14645@xxxxxxxxxxxxxxxxx>
On Jan 15, 4:44pm, Peter Stephenson wrote:
} Subject: PATCH: zsh-3.1.5-pws-4 + typeset fix: memory leak
}
} the problem with your approach is that `print -P' can take more than
} one argument, and all need freeing: the easiest thing to do is use
} heap memory (which gets freed automatically when the builtin exits),
} and free the permanent memory straight away.
Another place where 3.0.5 appears to have been patched but 3.1.5 has not.
The 3.0.5 code reads:
/* -P option -- interpret as a prompt sequence */
if(ops['P']) {
char *arg = putprompt(metafy(args[n], len[n], META_NOALLOC),
&len[n], NULL, 0);
args[n] = (char *)alloc(len[n] + 1);
memcpy(args[n], arg, len[n]);
args[n][len[n]] = 0;
free(arg);
}
I'm sure the memcpy() is done to avoid recomputing len[n]+1 in dupstring().
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author