Make paste_get_top return a copy of the buffer name which is more

sensible and avoids a double free pointed out by DongHan Kim.
This commit is contained in:
nicm
2026-02-11 08:30:37 +00:00
parent 5b455abecc
commit 7e50eb0e83
4 changed files with 27 additions and 24 deletions

View File

@@ -107,7 +107,7 @@ paste_is_empty(void)
/* Get the most recent automatic buffer. */
struct paste_buffer *
paste_get_top(const char **name)
paste_get_top(char **name)
{
struct paste_buffer *pb;
@@ -117,7 +117,7 @@ paste_get_top(const char **name)
if (pb == NULL)
return (NULL);
if (name != NULL)
*name = pb->name;
*name = xstrdup(pb->name);
return (pb);
}