lib: check NULL before freeing passwd data
Add an additional NULL check condition in spw_free() and pw_free() to avoid freeing an already empty pointer. Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
This commit is contained in:
@ -79,11 +79,13 @@
|
||||
|
||||
void spw_free (/*@out@*/ /*@only@*/struct spwd *spent)
|
||||
{
|
||||
free (spent->sp_namp);
|
||||
if (NULL != spent->sp_pwdp) {
|
||||
memzero (spent->sp_pwdp, strlen (spent->sp_pwdp));
|
||||
free (spent->sp_pwdp);
|
||||
if (spent != NULL) {
|
||||
free (spent->sp_namp);
|
||||
if (NULL != spent->sp_pwdp) {
|
||||
memzero (spent->sp_pwdp, strlen (spent->sp_pwdp));
|
||||
free (spent->sp_pwdp);
|
||||
}
|
||||
free (spent);
|
||||
}
|
||||
free (spent);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user