Don't allow multiple buffers with the same name, from Thomas Adam.

This commit is contained in:
nicm 2014-05-13 22:54:18 +00:00
parent b3e8d440ed
commit b2e791b574

11
paste.c
View File

@ -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;
@ -195,7 +195,14 @@ paste_rename(const char *oldname, const char *newname, char **cause)
pb = paste_get_name(oldname);
if (pb == NULL) {
if (cause != NULL)
xasprintf(cause, "no buffer %s", oldname);
xasprintf(cause, "no buffer %s", oldname);
return (-1);
}
pb_new = paste_get_name(newname);
if (pb_new != NULL) {
if (cause != NULL)
xasprintf(cause, "buffer %s already exists", newname);
return (-1);
}