mirror of
https://github.com/tmux/tmux.git
synced 2025-01-26 07:58:55 +00:00
When replacing, don't free the old paste until after the new one's name
has been copied. Fixes a use-after-free in window-copy.c. Bug reported by J Raynor (who also provided a different fix).
This commit is contained in:
parent
3aa72b42b2
commit
6920be311b
6
paste.c
6
paste.c
@ -247,9 +247,6 @@ paste_set(char *data, size_t size, const char *name, char **cause)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
pb = paste_get_name(name);
|
||||
if (pb != NULL)
|
||||
paste_free_name(name);
|
||||
|
||||
pb = xmalloc(sizeof *pb);
|
||||
|
||||
@ -261,6 +258,9 @@ paste_set(char *data, size_t size, const char *name, char **cause)
|
||||
pb->automatic = 0;
|
||||
pb->order = paste_next_order++;
|
||||
|
||||
if (paste_get_name(name) != NULL)
|
||||
paste_free_name(name);
|
||||
|
||||
RB_INSERT(paste_name_tree, &paste_by_name, pb);
|
||||
RB_INSERT(paste_time_tree, &paste_by_time, pb);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user