Skip to content

Commit

Permalink
libsemanage: fix memory leak in semanage_user_roles
Browse files Browse the repository at this point in the history
The output parameter `role_arr` of semanage_user_get_roles() is an array
of non-owned role names.  Since the array is never used again, as its
contents have been copied into the return value `roles`, free it.

Example leak report from useradd(8):

    Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x5597624284a8 in __interceptor_calloc (./shadow/src/useradd+0xee4a8)
    #1 0x7f53aefcbbf9 in sepol_user_get_roles src/user_record.c:270:21
  • Loading branch information
cgzones authored and jwcart2 committed May 3, 2023
1 parent b5dffcd commit 3be312e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions libsemanage/src/seusers_local.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static char *semanage_user_roles(semanage_handle_t * handle, const char *sename)
}
}
}
free(roles_arr);
}
semanage_user_free(user);
}
Expand Down

0 comments on commit 3be312e

Please sign in to comment.