From 7c085997397f58d1c53e0092e796de4d0a9ff2fd Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 26 Jun 2013 20:28:42 +0800 Subject: [PATCH v2 3/4] dbus-launch: check SIGHUP definition and free args on failure Signed-off-by: Chengwei Yang --- tools/dbus-launch.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 99143a6..b44b639 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -475,7 +475,9 @@ kill_bus_when_session_ends (void) act.sa_handler = signal_handler; act.sa_mask = empty_mask; act.sa_flags = 0; +#ifdef SIGHUP sigaction (SIGHUP, &act, NULL); +#endif sigaction (SIGTERM, &act, NULL); sigaction (SIGINT, &act, NULL); @@ -767,7 +769,11 @@ pass_info (const char *runprog, const char *bus_address, pid_t bus_pid, size_t len = strlen (argv[remaining_args+i-1])+1; args[i] = malloc (len); if (!args[i]) - goto oom; + { + while (i > 1) + free(args[--i]); + goto oom; + } strncpy (args[i], argv[remaining_args+i-1], len); } args[i] = NULL; -- 1.7.9.5