From: nicm Date: Tue, 2 Mar 2021 11:00:38 +0000 (+0000) Subject: Do not use NULL active window; also do not leak window name. GitHub X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c6ae53936380970d43490a262e4af2fc1b12878d;p=openbsd Do not use NULL active window; also do not leak window name. GitHub issue 2590 from Chester Liu. --- diff --git a/usr.bin/tmux/names.c b/usr.bin/tmux/names.c index db826680878..01462c4778c 100644 --- a/usr.bin/tmux/names.c +++ b/usr.bin/tmux/names.c @@ -1,4 +1,4 @@ -/* $OpenBSD: names.c,v 1.43 2020/10/05 11:04:40 nicm Exp $ */ +/* $OpenBSD: names.c,v 1.44 2021/03/02 11:00:38 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -109,6 +109,8 @@ default_window_name(struct window *w) { char *cmd, *s; + if (w->active == NULL) + return (xstrdup("")); cmd = cmd_stringify_argv(w->active->argc, w->active->argv); if (cmd != NULL && *cmd != '\0') s = parse_window_name(cmd); diff --git a/usr.bin/tmux/spawn.c b/usr.bin/tmux/spawn.c index 5a03c5fa80c..d44420fa6e8 100644 --- a/usr.bin/tmux/spawn.c +++ b/usr.bin/tmux/spawn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spawn.c,v 1.26 2021/03/02 10:56:45 nicm Exp $ */ +/* $OpenBSD: spawn.c,v 1.27 2021/03/02 11:00:38 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott @@ -184,7 +184,7 @@ spawn_window(struct spawn_context *sc, char **cause) NULL); options_set_number(w->options, "automatic-rename", 0); } else - w->name = xstrdup(default_window_name(w)); + w->name = default_window_name(w); } /* Switch to the new window if required. */