diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2003-10-06 22:46:24 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2003-10-06 22:46:24 +0000 |
commit | ed6a7ba60e87e1fd4b5c504d82c348e8dc415117 (patch) | |
tree | 97be429c165b5eff0b5ad4102a618deec333eac7 /Src/prompt.c | |
parent | bbc409eefece558f9b24ea6960e15c0c3468422a (diff) | |
download | zsh-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.c | 11 |
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); |