summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-14 22:31:03 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-14 23:18:33 +0100
commitb3fae863ef548add2d01c3956ce7720f4eeeca7e (patch)
treefd71be8bf3ca0c07e5356a34b6d987ed0d8310f7
parentbb4a228207815df88cdf68acd9e46ec19e0d3e30 (diff)
sysv-generator: fix memory leak on failure
This fixes a memory leak introduced by 1ed0c19f81fd13cdf283c6def0168ce122a853a9
-rw-r--r--src/sysv-generator/sysv-generator.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 2f24ef2561..89c0e7c67d 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -755,13 +755,11 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
service->name = name;
service->path = fpath;
- r = load_sysv(service);
- if (r < 0)
- continue;
-
r = hashmap_put(all_services, service->name, service);
- if (r < 0)
+ if (r < 0) {
+ free(service);
return log_oom();
+ }
name = fpath = NULL;
}
@@ -943,6 +941,12 @@ int main(int argc, char *argv[]) {
}
HASHMAP_FOREACH(service, all_services, j) {
+ q = load_sysv(service);
+ if (q < 0)
+ continue;
+ }
+
+ HASHMAP_FOREACH(service, all_services, j) {
q = fix_order(service, all_services);
if (q < 0)
continue;