summaryrefslogtreecommitdiffstats
path: root/cmd-split-window.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2018-03-01 14:02:27 +0000
committerThomas Adam <thomas@xteddy.org>2018-03-01 14:02:27 +0000
commit3b8f92359d564f495fc8db1daa807bf5e8036545 (patch)
tree3e5e5078328f9dfbff0a2313a03da501b842cc0c /cmd-split-window.c
parent0ca9664ecf001bc7883ead43a1d426d1e9465564 (diff)
parent182357f24bc7e16d7d7c85cab0c61974f18df2e7 (diff)
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-split-window.c')
-rw-r--r--cmd-split-window.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 7c166830..c7889a2c 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -60,8 +60,8 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
struct window *w = wl->window;
struct window_pane *wp = item->target.wp, *new_wp = NULL;
struct environ *env;
- const char *cmd, *path, *shell, *template, *cwd;
- char **argv, *cause, *new_cause, *cp, *to_free = NULL;
+ const char *cmd, *path, *shell, *template, *tmp;
+ char **argv, *cause, *new_cause, *cp, *cwd;
u_int hlimit;
int argc, size, percentage;
enum layout_type type;
@@ -85,14 +85,12 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
argv = args->argv;
}
- if (args_has(args, 'c')) {
- cwd = args_get(args, 'c');
- to_free = format_single(item, cwd, c, s, NULL, NULL);
- cwd = to_free;
- } else if (item->client != NULL && item->client->session == NULL)
- cwd = item->client->cwd;
+ if ((tmp = args_get(args, 'c')) != NULL)
+ cwd = format_single(item, tmp, c, s, NULL, NULL);
+ else if (item->client != NULL && item->client->session == NULL)
+ cwd = xstrdup(item->client->cwd);
else
- cwd = s->cwd;
+ cwd = xstrdup(s->cwd);
type = LAYOUT_TOPBOTTOM;
if (args_has(args, 'h'))
@@ -174,7 +172,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
cmd_find_from_winlink_pane(&fs, wl, new_wp, 0);
hooks_insert(s->hooks, item, &fs, "after-split-window");
- free(to_free);
+ free(cwd);
return (CMD_RETURN_NORMAL);
error:
@@ -185,6 +183,6 @@ error:
cmdq_error(item, "create pane failed: %s", cause);
free(cause);
- free(to_free);
+ free(cwd);
return (CMD_RETURN_ERROR);
}