=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/format.c,v retrieving revision 1.106 retrieving revision 1.107 diff -u -r1.106 -r1.107 --- src/usr.bin/tmux/format.c 2016/04/29 14:05:24 1.106 +++ src/usr.bin/tmux/format.c 2016/05/23 20:39:26 1.107 @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.106 2016/04/29 14:05:24 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.107 2016/05/23 20:39:26 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -850,27 +850,18 @@ 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); + if (strftime(s, sizeof s, fmt, tm) == 0) + return (xstrdup("")); - do { - tmp = xreallocarray(tmp, 2, tmplen); - tmplen *= 2; - } while (strftime(tmp, tmplen, fmt, tm) == 0); - - expanded = format_expand(ft, tmp); - free(tmp); - - return (expanded); + return (format_expand(ft, s)); } /* Expand keys in a template. */