summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-10-24 14:26:07 +0200
committerTyge Løvset <[email protected]>2020-10-24 14:26:07 +0200
commitaee8714e172c247a81a9f7069602b96aa389d719 (patch)
tree455f8e5398a4a3a795f0170508f263a32bc1843d
parent071d3d1e2e6d2e1ed8a4bf92db86ef407cc454c0 (diff)
downloadSTC-modified-aee8714e172c247a81a9f7069602b96aa389d719.tar.gz
STC-modified-aee8714e172c247a81a9f7069602b96aa389d719.zip
Make sure returned buf is null terminated on unseuccessful strftime.
-rw-r--r--stc/cfmt.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/stc/cfmt.h b/stc/cfmt.h
index 7a3ea90a..1a0416a8 100644
--- a/stc/cfmt.h
+++ b/stc/cfmt.h
@@ -33,7 +33,7 @@ STC_API char* _cfmt_conv(int nargs, const char *fmt, ...);
enum {_cfmt_bn=4, _cfmt_sn=64};
STC_INLINE const char* _cfmt_strftime(char* n, char buf[][_cfmt_sn], size_t maxsize, const char *fmt, const struct tm *timeptr) {
if (*n >= _cfmt_bn) return fmt;
- int k = (*n)++;
+ int k = (*n)++; buf[k][0] = '\0';
strftime(buf[k], maxsize, fmt, timeptr);
return buf[k];
}