From aee8714e172c247a81a9f7069602b96aa389d719 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sat, 24 Oct 2020 14:26:07 +0200 Subject: Make sure returned buf is null terminated on unseuccessful strftime. --- stc/cfmt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]; } -- cgit v1.2.3