diff options
Diffstat (limited to 'src/basic/unit-name.c')
-rw-r--r-- | src/basic/unit-name.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c index bf52463d81..fa530da456 100644 --- a/src/basic/unit-name.c +++ b/src/basic/unit-name.c @@ -673,6 +673,7 @@ int unit_name_mangle_with_suffix(const char *name, UnitNameMangle allow_globs, c int slice_build_parent_slice(const char *slice, char **ret) { char *s, *dash; + int r; assert(slice); assert(ret); @@ -693,11 +694,11 @@ int slice_build_parent_slice(const char *slice, char **ret) { if (dash) strcpy(dash, ".slice"); else { - free(s); - - s = strdup("-.slice"); - if (!s) - return -ENOMEM; + r = free_and_strdup(&s, "-.slice"); + if (r < 0) { + free(s); + return r; + } } *ret = s; |