mirror of
https://github.com/tmux/tmux.git
synced 2026-10-12 13:44:44 +00:00
Do not use stale pointers in modes.
This commit is contained in:
@@ -73,6 +73,7 @@ const struct window_mode window_client_mode = {
|
|||||||
|
|
||||||
struct window_client_itemdata {
|
struct window_client_itemdata {
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
char *ttyname;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct window_client_modedata {
|
struct window_client_modedata {
|
||||||
@@ -110,6 +111,7 @@ static void
|
|||||||
window_client_free_item(struct window_client_itemdata *item)
|
window_client_free_item(struct window_client_itemdata *item)
|
||||||
{
|
{
|
||||||
server_client_unref(item->c);
|
server_client_unref(item->c);
|
||||||
|
free(item->ttyname);
|
||||||
free(item);
|
free(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +139,7 @@ window_client_build(void *modedata, struct sort_criteria *sort_crit,
|
|||||||
|
|
||||||
item = window_client_add_item(data);
|
item = window_client_add_item(data);
|
||||||
item->c = l[i];
|
item->c = l[i];
|
||||||
|
item->ttyname = xstrdup(l[i]->ttyname);
|
||||||
|
|
||||||
l[i]->references++;
|
l[i]->references++;
|
||||||
}
|
}
|
||||||
@@ -381,7 +384,7 @@ window_client_key(struct window_mode_entry *wme, struct client *c,
|
|||||||
break;
|
break;
|
||||||
case '\r':
|
case '\r':
|
||||||
item = mode_tree_get_current(mtd);
|
item = mode_tree_get_current(mtd);
|
||||||
mode_tree_run_command(c, NULL, data->command, item->c->ttyname);
|
mode_tree_run_command(c, NULL, data->command, item->ttyname);
|
||||||
finished = 1;
|
finished = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ window_tree_build_window(struct session *s, struct winlink *wl,
|
|||||||
u_int n, i;
|
u_int n, i;
|
||||||
int expanded;
|
int expanded;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
|
uint64_t tag = FORMAT_NONE;
|
||||||
|
|
||||||
item = window_tree_add_item(data);
|
item = window_tree_add_item(data);
|
||||||
item->type = WINDOW_TREE_WINDOW;
|
item->type = WINDOW_TREE_WINDOW;
|
||||||
@@ -261,7 +262,9 @@ window_tree_build_window(struct session *s, struct winlink *wl,
|
|||||||
item->winlink = wl->idx;
|
item->winlink = wl->idx;
|
||||||
item->pane = -1;
|
item->pane = -1;
|
||||||
|
|
||||||
ft = format_create(NULL, NULL, FORMAT_PANE|wl->window->active->id, 0);
|
if (wl->window != NULL && wl->window->active != NULL)
|
||||||
|
tag = FORMAT_PANE|wl->window->active->id;
|
||||||
|
ft = format_create(NULL, NULL, tag, 0);
|
||||||
format_defaults(ft, NULL, s, wl, NULL);
|
format_defaults(ft, NULL, s, wl, NULL);
|
||||||
text = format_expand(ft, data->format);
|
text = format_expand(ft, data->format);
|
||||||
xasprintf(&name, "%u", wl->idx);
|
xasprintf(&name, "%u", wl->idx);
|
||||||
@@ -313,6 +316,7 @@ window_tree_build_session(struct session *s, void *modedata,
|
|||||||
u_int n, i, empty;
|
u_int n, i, empty;
|
||||||
int expanded;
|
int expanded;
|
||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
|
uint64_t tag = FORMAT_NONE;
|
||||||
|
|
||||||
item = window_tree_add_item(data);
|
item = window_tree_add_item(data);
|
||||||
item->type = WINDOW_TREE_SESSION;
|
item->type = WINDOW_TREE_SESSION;
|
||||||
@@ -320,7 +324,9 @@ window_tree_build_session(struct session *s, void *modedata,
|
|||||||
item->winlink = -1;
|
item->winlink = -1;
|
||||||
item->pane = -1;
|
item->pane = -1;
|
||||||
|
|
||||||
ft = format_create(NULL, NULL, FORMAT_PANE|wl->window->active->id, 0);
|
if (wl != NULL && wl->window != NULL && wl->window->active != NULL)
|
||||||
|
tag = FORMAT_PANE|wl->window->active->id;
|
||||||
|
ft = format_create(NULL, NULL, tag, 0);
|
||||||
format_defaults(ft, NULL, s, NULL, NULL);
|
format_defaults(ft, NULL, s, NULL, NULL);
|
||||||
text = format_expand(ft, data->format);
|
text = format_expand(ft, data->format);
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
|
|||||||
Reference in New Issue
Block a user