summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2014-03-31 21:43:56 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2014-03-31 21:43:56 +0000
commit2569373d3ed5aae2f28fbc283e0f889c47a3da10 (patch)
tree7355e7874d6418cce6089fb8d9f384dce9c762d3
parent0468e52a4d27234bbc3fd8a2907e248fa8846b92 (diff)
Don't crash with a zero-length argument to setb, from J Raynor.
-rw-r--r--usr.bin/tmux/cmd-set-buffer.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/tmux/cmd-set-buffer.c b/usr.bin/tmux/cmd-set-buffer.c
index 2d1c08c3b11..6a793f49c89 100644
--- a/usr.bin/tmux/cmd-set-buffer.c
+++ b/usr.bin/tmux/cmd-set-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-set-buffer.c,v 1.15 2014/03/31 21:39:31 nicm Exp $ */
+/* $OpenBSD: cmd-set-buffer.c,v 1.16 2014/03/31 21:43:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -56,6 +56,9 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
pb = NULL;
buffer = -1;
+ if ((newsize = strlen(args->argv[0])) == 0)
+ return (CMD_RETURN_NORMAL);
+
if (args_has(args, 'b')) {
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
if (cause != NULL) {
@@ -80,8 +83,6 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
memcpy(pdata, pb->data, psize);
}
- newsize = strlen(args->argv[0]);
-
pdata = xrealloc(pdata, 1, psize + newsize);
memcpy(pdata + psize, args->argv[0], newsize);
psize += newsize;