From f211604396143370f46cf0b99d3e288fab91a9fd Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Tue, 17 Jan 2006 22:14:40 +0000 Subject: Tweaked the code that handles %D so that: (1) we don't free() a NULL pointer (we use zsfree() instead), and (2) we avoid a rare bug that could call free() on same memory twice (e.g. "%D{}%D"). --- Src/prompt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Src/prompt.c b/Src/prompt.c index c09626e30..e45e9573e 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -207,7 +207,7 @@ promptexpand(char *s, int ns, char *rs, char *Rs) static int putpromptchar(int doprint, int endchar) { - char *ss, *tmbuf = NULL, *hostnam; + char *ss, *hostnam; int t0, arg, test, sep, j, numjobs; struct tm *tm; time_t timet; @@ -489,7 +489,7 @@ putpromptchar(int doprint, int endchar) case 'W': case 'D': { - char *tmfmt, *dd; + char *tmfmt, *dd, *tmbuf = NULL; switch (*fm) { case 'T': @@ -547,8 +547,7 @@ putpromptchar(int doprint, int endchar) * allocates room for t0 * 2 bytes. */ metafy(bp, -1, META_NOALLOC); bp += strlen(bp); - free(tmbuf); - tmbuf = NULL; + zsfree(tmbuf); break; } case 'n': -- cgit 1.4.1