[PATCH] Don't call execvp() with NULL as first argument

From: Peter Hofmann <scm_AT_uninformativ.de>
Date: Sun, 14 Aug 2016 12:00:51 +0200

This fixes a crash (on some platforms) in the child process in scenarios
like this:

    $ tabbed -d
    0x3000003
    $ xterm -into 0x3000003
    [hit Ctrl+Shift+Return in tabbed]
---
 tabbed.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tabbed.c b/tabbed.c
index 9a44795..964c40d 100644
--- a/tabbed.c
+++ b/tabbed.c
_AT_@ -1080,16 +1080,21 @@ spawn(const Arg *arg)
 			close(ConnectionNumber(dpy));
 
 		setsid();
-		if (arg && arg->v) {
+		if (arg && arg->v && ((char **)arg->v)[0]) {
 			execvp(((char **)arg->v)[0], (char **)arg->v);
 			fprintf(stderr, "%s: execvp %s", argv0,
 			        ((char **)arg->v)[0]);
-		} else {
+			perror(" failed");
+		} else if (cmd[0]) {
 			cmd[cmd_append_pos] = NULL;
 			execvp(cmd[0], cmd);
 			fprintf(stderr, "%s: execvp %s", argv0, cmd[0]);
+			perror(" failed");
+		}
+		else {
+			fprintf(stderr, "%s: Cannot spawn process, no command given\n",
+			        argv0);
 		}
-		perror(" failed");
 		exit(0);
 	}
 }
-- 
2.9.2
--SkvwRMAIpAhPCcCJ--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 14 2016 - 15:36:05 CEST