diff options
author | nicm <nicm> | 2016-05-23 20:39:26 +0000 |
---|---|---|
committer | nicm <nicm> | 2016-05-23 20:39:26 +0000 |
commit | 95a4cc3bcef95feb6dfca7557cef4c32a424e4d4 (patch) | |
tree | 6a6176d29a8e81e7b899be94c986909fa43fb532 | |
parent | e81a92449ea45b58cc6ff8ae1d7d46bf6b312694 (diff) | |
download | rtmux-95a4cc3bcef95feb6dfca7557cef4c32a424e4d4.tar.gz rtmux-95a4cc3bcef95feb6dfca7557cef4c32a424e4d4.tar.bz2 rtmux-95a4cc3bcef95feb6dfca7557cef4c32a424e4d4.zip |
Use a fixed buffer for strftime() because there is no portable way to
tell if the buffer is too small, and an expanding buffer is overkill
anyway.
-rw-r--r-- | format.c | 17 |
1 files changed, 4 insertions, 13 deletions
@@ -850,27 +850,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. */ |