unit-name: fix memory leak

Fix a memory leak introduced by 2fc09a9c. 's' is used twice in this
function, and if free_and_strdup() fails, the pointer is left untouched.
This commit is contained in:
Daniel Mack
2015-07-30 15:51:50 +02:00
parent ed070f131f
commit 8e542fcdc4

View File

@@ -695,8 +695,10 @@ int slice_build_parent_slice(const char *slice, char **ret) {
strcpy(dash, ".slice");
else {
r = free_and_strdup(&s, "-.slice");
if (r < 0)
if (r < 0) {
free(s);
return r;
}
}
*ret = s;