diff options
Diffstat (limited to 'usr.bin/tmux/cmd-new-session.c')
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index c35c00b0c09..337e0ffd728 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.140 2021/08/20 18:59:53 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.141 2021/08/20 19:50:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -79,8 +79,8 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) char *cause, *cwd = NULL, *cp, *newname = NULL; char *name, *prefix = NULL; int detached, already_attached, is_control = 0; - u_int sx, sy, dsx, dsy; - struct spawn_context sc; + u_int sx, sy, dsx, dsy, count = args_count(args); + struct spawn_context sc = { 0 }; enum cmd_retval retval; struct cmd_find_state fs; struct args_value *av; @@ -93,7 +93,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) return (CMD_RETURN_NORMAL); } - if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) { + if (args_has(args, 't') && (count != 0 || args_has(args, 'n'))) { cmdq_error(item, "command or window name given with target"); return (CMD_RETURN_ERROR); } @@ -277,15 +277,13 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) s = session_create(prefix, newname, cwd, env, oo, tiop); /* Spawn the initial window. */ - memset(&sc, 0, sizeof sc); sc.item = item; sc.s = s; if (!detached) sc.tc = c; sc.name = args_get(args, 'n'); - sc.argc = args->argc; - sc.argv = args->argv; + args_vector(args, &sc.argc, &sc.argv); sc.idx = -1; sc.cwd = args_get(args, 'c'); @@ -358,12 +356,16 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) cmd_find_from_session(&fs, s, 0); cmdq_insert_hook(s, item, &fs, "after-new-session"); + if (sc.argv != NULL) + cmd_free_argv(sc.argc, sc.argv); free(cwd); free(newname); free(prefix); return (CMD_RETURN_NORMAL); fail: + if (sc.argv != NULL) + cmd_free_argv(sc.argc, sc.argv); free(cwd); free(newname); free(prefix); |