summaryrefslogtreecommitdiffstats
path: root/cmd-set-buffer.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2014-03-24 12:00:15 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2014-03-24 12:00:15 +0000
commit26c42ad1e4bf8db443c5e2cbb14c0b82329a6137 (patch)
tree043659bd6e545e783b5560c8bc27ef2a0ade4f1f /cmd-set-buffer.c
parent77603c4f2de1961b3da141b3e6e4ce2f983365d4 (diff)
Don't crash with a zero-length argument to setb, from J Raynor.
Diffstat (limited to 'cmd-set-buffer.c')
-rw-r--r--cmd-set-buffer.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c
index 0e754bb6..e7f9b95d 100644
--- a/cmd-set-buffer.c
+++ b/cmd-set-buffer.c
@@ -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;