about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2006-01-17 22:14:40 +0000
committerWayne Davison <wayned@users.sourceforge.net>2006-01-17 22:14:40 +0000
commitf211604396143370f46cf0b99d3e288fab91a9fd (patch)
tree6539964b8ccfd57ce7590cc73b227a37cea76d57 /Src
parent434ff125f05657a8f198c316c18f8626c262e7e9 (diff)
downloadzsh-f211604396143370f46cf0b99d3e288fab91a9fd.tar.gz
zsh-f211604396143370f46cf0b99d3e288fab91a9fd.tar.xz
zsh-f211604396143370f46cf0b99d3e288fab91a9fd.zip
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").
Diffstat (limited to 'Src')
-rw-r--r--Src/prompt.c7
1 files 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':