1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

Merge pull request #8754 from poettering/sysusers-fix

two minor memleak fixes for sysusers, fixing #8718
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-04-19 19:39:48 +02:00 committed by GitHub
commit d18b57f7fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -48,7 +48,6 @@ static void uid_range_coalesce(UidRange **p, unsigned *n) {
}
}
}
}
static int uid_range_compare(const void *a, const void *b) {

View File

@ -97,8 +97,8 @@ static int load_user_database(void) {
return r;
while ((r = fgetpwent_sane(f, &pw)) > 0) {
char *n;
int k, q;
char *n;
n = strdup(pw->pw_name);
if (!n)
@ -112,12 +112,12 @@ static int load_user_database(void) {
q = hashmap_put(database_uid, UID_TO_PTR(pw->pw_uid), n);
if (q < 0 && q != -EEXIST) {
if (k < 0)
if (k <= 0)
free(n);
return q;
}
if (q < 0 && k < 0)
if (q <= 0 && k <= 0)
free(n);
}
return r;
@ -159,12 +159,12 @@ static int load_group_database(void) {
q = hashmap_put(database_gid, GID_TO_PTR(gr->gr_gid), n);
if (q < 0 && q != -EEXIST) {
if (k < 0)
if (k <= 0)
free(n);
return q;
}
if (q < 0 && k < 0)
if (q <= 0 && k <= 0)
free(n);
errno = 0;
@ -1960,10 +1960,10 @@ int main(int argc, char *argv[]) {
}
ORDERED_HASHMAP_FOREACH(i, groups, iterator)
process_item(i);
(void) process_item(i);
ORDERED_HASHMAP_FOREACH(i, users, iterator)
process_item(i);
(void) process_item(i);
r = write_files();
if (r < 0)
@ -1985,6 +1985,8 @@ finish:
free_database(database_user, database_uid);
free_database(database_group, database_gid);
free(uid_range);
free(arg_root);
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;