Do not allow paste into panes which have exited, from Romain Francoise

in GitHub issue 3830.
This commit is contained in:
nicm 2024-02-13 08:03:50 +00:00
parent 428f8a9b28
commit 4bdb855020
4 changed files with 13 additions and 1 deletions

View File

@ -55,6 +55,11 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmdq_item *item)
size_t seplen, bufsize; size_t seplen, bufsize;
int bracket = args_has(args, 'p'); int bracket = args_has(args, 'p');
if (window_pane_exited(wp)) {
cmdq_error(item, "target pane has exited");
return (CMD_RETURN_ERROR);
}
bufname = NULL; bufname = NULL;
if (args_has(args, 'b')) if (args_has(args, 'b'))
bufname = args_get(args, 'b'); bufname = args_get(args, 'b');

View File

@ -69,7 +69,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
sigset_t set, oldset; sigset_t set, oldset;
/* Do nothing if pane is dead. */ /* Do nothing if pane is dead. */
if (wp->fd == -1 || (wp->flags & PANE_EXITED)) { if (window_pane_exited(wp)) {
cmdq_error(item, "target pane has exited"); cmdq_error(item, "target pane has exited");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }

1
tmux.h
View File

@ -3047,6 +3047,7 @@ int window_pane_key(struct window_pane *, struct client *,
struct session *, struct winlink *, key_code, struct session *, struct winlink *, key_code,
struct mouse_event *); struct mouse_event *);
int window_pane_visible(struct window_pane *); int window_pane_visible(struct window_pane *);
int window_pane_exited(struct window_pane *);
u_int window_pane_search(struct window_pane *, const char *, int, u_int window_pane_search(struct window_pane *, const char *, int,
int); int);
const char *window_printable_flags(struct winlink *, int); const char *window_printable_flags(struct winlink *, int);

View File

@ -1204,6 +1204,12 @@ window_pane_visible(struct window_pane *wp)
return (wp == wp->window->active); return (wp == wp->window->active);
} }
int
window_pane_exited(struct window_pane *wp)
{
return (wp->fd == -1 || (wp->flags & PANE_EXITED));
}
u_int u_int
window_pane_search(struct window_pane *wp, const char *term, int regex, window_pane_search(struct window_pane *wp, const char *term, int regex,
int ignore) int ignore)