sysv-generator: fix memory leak on failure

This fixes a memory leak introduced by
1ed0c19f81
This commit is contained in:
Lennart Poettering 2015-01-14 22:31:03 +01:00
parent bb4a228207
commit b3fae863ef
1 changed files with 9 additions and 5 deletions

View File

@ -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;
}
@ -942,6 +940,12 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
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)