mirror of
https://github.com/tmux/tmux.git
synced 2024-11-17 09:58:52 +00:00
Pass flags into cmdq_guard as an argument since sometimes cmdq->cmd can be
NULL. Avoids crash when a command in a command client can't be parsed.
This commit is contained in:
parent
7ea560261c
commit
1c271852fc
16
cmd-queue.c
16
cmd-queue.c
@ -154,18 +154,15 @@ cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
|
|||||||
|
|
||||||
/* Print a guard line. */
|
/* Print a guard line. */
|
||||||
int
|
int
|
||||||
cmdq_guard(struct cmd_q *cmdq, const char *guard)
|
cmdq_guard(struct cmd_q *cmdq, const char *guard, int flags)
|
||||||
{
|
{
|
||||||
struct client *c = cmdq->client;
|
struct client *c = cmdq->client;
|
||||||
int flags;
|
|
||||||
|
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if (!(c->flags & CLIENT_CONTROL))
|
if (!(c->flags & CLIENT_CONTROL))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
flags = !!(cmdq->cmd->flags & CMD_CONTROL);
|
|
||||||
|
|
||||||
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u %d\n", guard,
|
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u %d\n", guard,
|
||||||
(long) cmdq->time, cmdq->number, flags);
|
(long) cmdq->time, cmdq->number, flags);
|
||||||
server_push_stdout(c);
|
server_push_stdout(c);
|
||||||
@ -202,7 +199,7 @@ cmdq_continue(struct cmd_q *cmdq)
|
|||||||
{
|
{
|
||||||
struct cmd_q_item *next;
|
struct cmd_q_item *next;
|
||||||
enum cmd_retval retval;
|
enum cmd_retval retval;
|
||||||
int empty, guard;
|
int empty, guard, flags;
|
||||||
char s[1024];
|
char s[1024];
|
||||||
|
|
||||||
notify_disable();
|
notify_disable();
|
||||||
@ -228,13 +225,16 @@ cmdq_continue(struct cmd_q *cmdq)
|
|||||||
cmdq->time = time(NULL);
|
cmdq->time = time(NULL);
|
||||||
cmdq->number++;
|
cmdq->number++;
|
||||||
|
|
||||||
guard = cmdq_guard(cmdq, "begin");
|
flags = !!(cmdq->cmd->flags & CMD_CONTROL);
|
||||||
|
guard = cmdq_guard(cmdq, "begin", flags);
|
||||||
|
|
||||||
retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq);
|
retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq);
|
||||||
|
|
||||||
if (guard) {
|
if (guard) {
|
||||||
if (retval == CMD_RETURN_ERROR)
|
if (retval == CMD_RETURN_ERROR)
|
||||||
cmdq_guard(cmdq, "error");
|
cmdq_guard(cmdq, "error", flags);
|
||||||
else
|
else
|
||||||
cmdq_guard(cmdq, "end");
|
cmdq_guard(cmdq, "end", flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retval == CMD_RETURN_ERROR)
|
if (retval == CMD_RETURN_ERROR)
|
||||||
|
@ -73,9 +73,9 @@ control_callback(struct client *c, int closed, unused void *data)
|
|||||||
c->cmdq->time = time(NULL);
|
c->cmdq->time = time(NULL);
|
||||||
c->cmdq->number++;
|
c->cmdq->number++;
|
||||||
|
|
||||||
cmdq_guard(c->cmdq, "begin");
|
cmdq_guard(c->cmdq, "begin", 1);
|
||||||
control_write(c, "parse error: %s", cause);
|
control_write(c, "parse error: %s", cause);
|
||||||
cmdq_guard(c->cmdq, "error");
|
cmdq_guard(c->cmdq, "error", 1);
|
||||||
|
|
||||||
free(cause);
|
free(cause);
|
||||||
} else {
|
} else {
|
||||||
|
2
tmux.h
2
tmux.h
@ -1868,7 +1868,7 @@ int cmdq_free(struct cmd_q *);
|
|||||||
void printflike2 cmdq_print(struct cmd_q *, const char *, ...);
|
void printflike2 cmdq_print(struct cmd_q *, const char *, ...);
|
||||||
void printflike2 cmdq_info(struct cmd_q *, const char *, ...);
|
void printflike2 cmdq_info(struct cmd_q *, const char *, ...);
|
||||||
void printflike2 cmdq_error(struct cmd_q *, const char *, ...);
|
void printflike2 cmdq_error(struct cmd_q *, const char *, ...);
|
||||||
int cmdq_guard(struct cmd_q *, const char *);
|
int cmdq_guard(struct cmd_q *, const char *, int);
|
||||||
void cmdq_run(struct cmd_q *, struct cmd_list *);
|
void cmdq_run(struct cmd_q *, struct cmd_list *);
|
||||||
void cmdq_append(struct cmd_q *, struct cmd_list *);
|
void cmdq_append(struct cmd_q *, struct cmd_list *);
|
||||||
int cmdq_continue(struct cmd_q *);
|
int cmdq_continue(struct cmd_q *);
|
||||||
|
Loading…
Reference in New Issue
Block a user