diff options
author | Karel Zak <kzak@redhat.com> | 2014-07-25 15:38:31 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-26 15:08:41 -0400 |
commit | 7de80bfe2e61d5818601ccfddbadad3b7703ed70 (patch) | |
tree | b8b90c03198f2f2125d13e175b2223e6239894f0 /src/run/run.c | |
parent | 6d314eca15f6cbda38d82774b210f784d3d4f52a (diff) |
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.
Diffstat (limited to 'src/run/run.c')
-rw-r--r-- | src/run/run.c | 16 |
1 files changed, 8 insertions, 8 deletions
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); |