mirror of
https://github.com/tmux/tmux.git
synced 2024-12-14 10:58:48 +00:00
Don't allow multiple buffers with the same name, from Thomas Adam.
This commit is contained in:
parent
b3e8d440ed
commit
b2e791b574
9
paste.c
9
paste.c
@ -176,7 +176,7 @@ paste_add(char *data, size_t size)
|
||||
int
|
||||
paste_rename(const char *oldname, const char *newname, char **cause)
|
||||
{
|
||||
struct paste_buffer *pb;
|
||||
struct paste_buffer *pb, *pb_new;
|
||||
|
||||
if (cause != NULL)
|
||||
*cause = NULL;
|
||||
@ -199,6 +199,13 @@ paste_rename(const char *oldname, const char *newname, char **cause)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
pb_new = paste_get_name(newname);
|
||||
if (pb_new != NULL) {
|
||||
if (cause != NULL)
|
||||
xasprintf(cause, "buffer %s already exists", newname);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
RB_REMOVE(paste_name_tree, &paste_by_name, pb);
|
||||
|
||||
free(pb->name);
|
||||
|
Loading…
Reference in New Issue
Block a user