about summary refs log tree commit diff
path: root/Src/prompt.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2003-10-06 22:46:24 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2003-10-06 22:46:24 +0000
commited6a7ba60e87e1fd4b5c504d82c348e8dc415117 (patch)
tree97be429c165b5eff0b5ad4102a618deec333eac7 /Src/prompt.c
parentbbc409eefece558f9b24ea6960e15c0c3468422a (diff)
downloadzsh-ed6a7ba60e87e1fd4b5c504d82c348e8dc415117.tar.gz
zsh-ed6a7ba60e87e1fd4b5c504d82c348e8dc415117.tar.xz
zsh-ed6a7ba60e87e1fd4b5c504d82c348e8dc415117.zip
19168: Various problems with size of buffers and pointer usage in ztrftime
Diffstat (limited to 'Src/prompt.c')
-rw-r--r--Src/prompt.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Src/prompt.c b/Src/prompt.c
index ac96ad340..dc31eddb6 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -500,18 +500,23 @@ putpromptchar(int doprint, int endchar)
 			tmfmt = "%m/%d/%y";
 			break;
 		    case 'D':
-			if (fm[1] == '{') /*}*/ {
+			if (fm[1] == '{' /*}*/) {
 			    for (ss = fm + 2; *ss && *ss != /*{*/ '}'; ss++)
 				if(*ss == '\\' && ss[1])
 				    ss++;
 			    dd = tmfmt = tmbuf = zalloc(ss - fm);
-			    for (ss = fm + 2; *ss && *ss != /*{*/ '}'; ss++) {
+			    for (ss = fm + 2; *ss && *ss != /*{*/ '}';
+				 ss++) {
 				if(*ss == '\\' && ss[1])
 				    ss++;
 				*dd++ = *ss;
 			    }
 			    *dd = 0;
 			    fm = ss - !*ss;
+			    if (!*tmfmt) {
+				free(tmbuf);
+				continue;
+			    }
 			} else
 			    tmfmt = "%y-%m-%d";
 			break;
@@ -523,7 +528,7 @@ putpromptchar(int doprint, int endchar)
 		    tm = localtime(&timet);
 		    for(t0=80; ; t0*=2) {
 			addbufspc(t0);
-			if(ztrftime(bp, t0, tmfmt, tm) != t0)
+			if (ztrftime(bp, t0, tmfmt, tm))
 			    break;
 		    }
 		    bp += strlen(bp);