diff options
author | 2018-02-20 10:43:46 +0000 | |
---|---|---|
committer | 2018-02-20 10:43:46 +0000 | |
commit | f89789bb56117a5c93ddaec7c1f73433a6120039 (patch) | |
tree | 8e5b201de904196572ae28a272657f4dc13ebdfc | |
parent | Call "vmctl stop" on each VM at shutdown, for OpenBSD guests this means they (diff) | |
download | wireguard-openbsd-f89789bb56117a5c93ddaec7c1f73433a6120039.tar.xz wireguard-openbsd-f89789bb56117a5c93ddaec7c1f73433a6120039.zip |
Do not leak memory when working out job name in formats.
-rw-r--r-- | usr.bin/tmux/format.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index c2b7f215fcc..83ebb7b1f21 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.151 2018/01/18 14:28:11 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.152 2018/02/20 10:43:46 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1121,7 +1121,7 @@ format_expand_time(struct format_tree *ft, const char *fmt, time_t t) char * format_expand(struct format_tree *ft, const char *fmt) { - char *buf, *out; + char *buf, *out, *name; const char *ptr, *s, *saved = fmt; size_t off, len, n, outlen; int ch, brackets; @@ -1160,8 +1160,11 @@ format_expand(struct format_tree *ft, const char *fmt) if (ft->flags & FORMAT_NOJOBS) out = xstrdup(""); - else - out = format_job_get(ft, xstrndup(fmt, n)); + else { + name = xstrndup(fmt, n); + out = format_job_get(ft, name); + free(name); + } outlen = strlen(out); while (len - off < outlen + 1) { |