From 7de80bfe2e61d5818601ccfddbadad3b7703ed70 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 25 Jul 2014 15:38:31 +0200 Subject: Always check asprintf return code There is a small number of the places in sources where we don't check asprintf() return code and assume that after error the function returns NULL pointer via the first argument. That's wrong, after error the content of pointer is undefined. --- src/run/run.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/run') diff --git a/src/run/run.c b/src/run/run.c index 9d5527b29c..b9be1455c4 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -335,11 +335,11 @@ static int start_transient_service( _cleanup_free_ char *name = NULL; int r; - if (arg_unit) + if (arg_unit) { name = unit_name_mangle_with_suffix(arg_unit, MANGLE_NOGLOB, ".service"); - else - asprintf(&name, "run-"PID_FMT".service", getpid()); - if (!name) + if (!name) + return log_oom(); + } else if (asprintf(&name, "run-"PID_FMT".service", getpid()) < 0) return log_oom(); r = message_start_transient_unit_new(bus, name, &m); @@ -471,11 +471,11 @@ static int start_transient_scope( assert(bus); - if (arg_unit) + if (arg_unit) { name = unit_name_mangle_with_suffix(arg_unit, MANGLE_NOGLOB, ".scope"); - else - asprintf(&name, "run-"PID_FMT".scope", getpid()); - if (!name) + if (!name) + return log_oom(); + } else if (asprintf(&name, "run-"PID_FMT".scope", getpid()) < 0) return log_oom(); r = message_start_transient_unit_new(bus, name, &m); -- cgit v1.2.3-54-g00ecf