summaryrefslogtreecommitdiff
path: root/src/basic/unit-name.c
diff options
context:
space:
mode:
authorDaniel Mack <daniel@zonque.org>2015-07-30 15:51:50 +0200
committerDaniel Mack <daniel@zonque.org>2015-07-30 15:51:50 +0200
commit8e542fcdc41db44895bbb7124909eea5fe2dea4d (patch)
tree24e2948c6d5fa47e2a28a8b1a3c612b347ec767c /src/basic/unit-name.c
parented070f131f774ff1f08ca36f832e5fe425da03dc (diff)
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.
Diffstat (limited to 'src/basic/unit-name.c')
-rw-r--r--src/basic/unit-name.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c
index 4b84542d0c..fa530da456 100644
--- a/src/basic/unit-name.c
+++ b/src/basic/unit-name.c
@@ -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;