The following will cause a fatal error in recent tmux code:

setb ""


The empty string leads to an xrealloc in cmd-set-buffer.c with a size
of 0, which is fatal.  I've attached a patch which fixes this.
diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c
index 0e754bb..e7f9b95 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;
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to