aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2016-05-24 00:01:09 +0100
committerThomas Adam <thomas@xteddy.org>2016-05-24 00:01:09 +0100
commit05ec232f3ec567351405f276693735056156527d (patch)
treee632cc51aca01f8c152356304dc95074fdb60a4b
parent266918a580e60c29a0d50753b4126cc4606ea223 (diff)
parent95a4cc3bcef95feb6dfca7557cef4c32a424e4d4 (diff)
downloadrtmux-05ec232f3ec567351405f276693735056156527d.tar.gz
rtmux-05ec232f3ec567351405f276693735056156527d.tar.bz2
rtmux-05ec232f3ec567351405f276693735056156527d.zip
Merge branch 'obsd-master'
-rw-r--r--format.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/format.c b/format.c
index e62738d5..20d35906 100644
--- a/format.c
+++ b/format.c
@@ -867,27 +867,18 @@ fail:
char *
format_expand_time(struct format_tree *ft, const char *fmt, time_t t)
{
- char *tmp, *expanded;
- size_t tmplen;
struct tm *tm;
+ char s[2048];
if (fmt == NULL || *fmt == '\0')
return (xstrdup(""));
tm = localtime(&t);
- tmp = NULL;
- tmplen = strlen(fmt);
-
- do {
- tmp = xreallocarray(tmp, 2, tmplen);
- tmplen *= 2;
- } while (strftime(tmp, tmplen, fmt, tm) == 0);
-
- expanded = format_expand(ft, tmp);
- free(tmp);
+ if (strftime(s, sizeof s, fmt, tm) == 0)
+ return (xstrdup(""));
- return (expanded);
+ return (format_expand(ft, s));
}
/* Expand keys in a template. */