summaryrefslogtreecommitdiffstats
path: root/cmd-set-buffer.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-09-07 18:50:45 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-09-07 18:50:45 +0000
commitccba613e5b277e70e8261c04ecc37ff3ef14a217 (patch)
tree26ed2fcf88ae87e4e76e922df255e4fd62589e31 /cmd-set-buffer.c
parente97006b102dd274dd8cc70c2aee13f6b09f69a41 (diff)
Give each paste buffer a size member instead of requiring them to be
zero-terminated.
Diffstat (limited to 'cmd-set-buffer.c')
-rw-r--r--cmd-set-buffer.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c
index 8c2b8441..2f624040 100644
--- a/cmd-set-buffer.c
+++ b/cmd-set-buffer.c
@@ -18,7 +18,7 @@
#include <sys/types.h>
-#include <stdlib.h>
+#include <string.h>
#include "tmux.h"
@@ -45,17 +45,23 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
struct cmd_buffer_data *data = self->data;
struct session *s;
u_int limit;
+ u_char *pdata;
+ size_t psize;
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return (-1);
-
limit = options_get_number(&s->options, "buffer-limit");
+
+ pdata = xstrdup(data->arg);
+ psize = strlen(pdata);
+
if (data->buffer == -1) {
- paste_add(&s->buffers, xstrdup(data->arg), limit);
+ paste_add(&s->buffers, pdata, psize, limit);
return (0);
}
- if (paste_replace(&s->buffers, data->buffer, xstrdup(data->arg)) != 0) {
+ if (paste_replace(&s->buffers, data->buffer, pdata, psize) != 0) {
ctx->error(ctx, "no buffer %d", data->buffer);
+ xfree(pdata);
return (-1);
}
return (0);