aboutsummaryrefslogtreecommitdiff
path: root/libpamc
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2023-12-14 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2023-12-14 08:00:00 +0000
commit954234f0a477636eab751a6601d34bab1db41b0e (patch)
tree83403cf711c78b112e2738eb82b35d801cce18ee /libpamc
parent297f0b554e497e95c891fd6a77f7ac5591649f26 (diff)
downloadpam-954234f0a477636eab751a6601d34bab1db41b0e.tar.gz
pam-954234f0a477636eab751a6601d34bab1db41b0e.tar.bz2
pam-954234f0a477636eab751a6601d34bab1db41b0e.zip
treewide: assume free(NULL) is no-op
The C standard guarantees that if the argument of free() is a null pointer, no action occurs.
Diffstat (limited to 'libpamc')
-rw-r--r--libpamc/pamc_load.c6
-rw-r--r--libpamc/test/modules/pam_secret.c4
2 files changed, 3 insertions, 7 deletions
diff --git a/libpamc/pamc_load.c b/libpamc/pamc_load.c
index 69fb8b87..f7365990 100644
--- a/libpamc/pamc_load.c
+++ b/libpamc/pamc_load.c
@@ -393,10 +393,8 @@ static pamc_id_node_t *__pamc_add_node(pamc_id_node_t *root, const char *id,
static pamc_id_node_t *__pamc_liberate_nodes(pamc_id_node_t *tree)
{
if (tree) {
- if (tree->agent_id) {
- free(tree->agent_id);
- tree->agent_id = NULL;
- }
+ free(tree->agent_id);
+ tree->agent_id = NULL;
tree->left = __pamc_liberate_nodes(tree->left);
tree->right = __pamc_liberate_nodes(tree->right);
diff --git a/libpamc/test/modules/pam_secret.c b/libpamc/test/modules/pam_secret.c
index f1c74c6f..c4b32ae9 100644
--- a/libpamc/test/modules/pam_secret.c
+++ b/libpamc/test/modules/pam_secret.c
@@ -171,9 +171,7 @@ static int converse(pam_handle_t *pamh, struct ps_state_s *new)
}
}
- if (single_reply) {
- free(single_reply);
- }
+ free(single_reply);
}
#ifdef PAM_DEBUG