summaryrefslogtreecommitdiffstats
path: root/cmd-set-buffer.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-01-25 18:51:28 +0000
committerTiago Cunha <tcunha@gmx.com>2009-01-25 18:51:28 +0000
commitd60ad6f483ddbe8ee2458aaef37b6f38140d63f5 (patch)
tree560d15228106845d2132b293318b05f07192377b /cmd-set-buffer.c
parent32903241a23b2e1f97e19f33086c0f77fd9aaa90 (diff)
Make the caller responsible for allocating memory for the paste buffer data
(needed by the load-buffer command when dealing with big files since it'll prevent tmux from dying due to memory exhaustion). From nicm.
Diffstat (limited to 'cmd-set-buffer.c')
-rw-r--r--cmd-set-buffer.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c
index dd8f4336..e5584b95 100644
--- a/cmd-set-buffer.c
+++ b/cmd-set-buffer.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-set-buffer.c,v 1.6 2009-01-19 18:23:40 nicm Exp $ */
+/* $Id: cmd-set-buffer.c,v 1.7 2009-01-25 18:51:28 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -52,12 +52,13 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
limit = options_get_number(&s->options, "buffer-limit");
- if (data->buffer == -1)
- paste_add(&s->buffers, data->arg, limit);
- else if (paste_replace(&s->buffers, data->buffer, data->arg) != 0) {
+ if (data->buffer == -1) {
+ paste_add(&s->buffers, xstrdup(data->arg), limit);
+ return (0);
+ }
+ if (paste_replace(&s->buffers, data->buffer, xstrdup(data->arg)) != 0) {
ctx->error(ctx, "no buffer %d", data->buffer);
return (-1);
}
-
return (0);
}