summaryrefslogtreecommitdiffstats
path: root/cmd-run-shell.c
diff options
context:
space:
mode:
authornicm <nicm>2020-03-13 06:19:33 +0000
committernicm <nicm>2020-03-13 06:19:33 +0000
commitfa36e9bc88cab7f721911bc56b397b9fd55dc038 (patch)
tree0a3825c4bfca4823585a62deee9297885ab6a8d5 /cmd-run-shell.c
parent6571dd50f86927595b6edd2d6fe4a8982b61d8c6 (diff)
Do not add a reference to the session if no session is present.
Diffstat (limited to 'cmd-run-shell.c')
-rw-r--r--cmd-run-shell.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/cmd-run-shell.c b/cmd-run-shell.c
index 5f207bbb..bc21cc9c 100644
--- a/cmd-run-shell.c
+++ b/cmd-run-shell.c
@@ -114,7 +114,8 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
cdata->cwd = xstrdup(server_client_get_cwd(item->client, s));
cdata->s = s;
- session_add_ref(s, __func__);
+ if (s != NULL)
+ session_add_ref(s, __func__);
evtimer_set(&cdata->timer, cmd_run_shell_timer, cdata);
@@ -203,7 +204,8 @@ cmd_run_shell_free(void *data)
struct cmd_run_shell_data *cdata = data;
evtimer_del(&cdata->timer);
- session_remove_ref(cdata->s, __func__);
+ if (cdata->s != NULL)
+ session_remove_ref(cdata->s, __func__);
free(cdata->cwd);
free(cdata->cmd);
free(cdata);