diff options
author | Dmitry V. Levin <ldv@strace.io> | 2023-12-14 08:00:00 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-12-14 08:00:00 +0000 |
commit | 954234f0a477636eab751a6601d34bab1db41b0e (patch) | |
tree | 83403cf711c78b112e2738eb82b35d801cce18ee /libpam | |
parent | 297f0b554e497e95c891fd6a77f7ac5591649f26 (diff) | |
download | pam-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 'libpam')
-rw-r--r-- | libpam/include/security/_pam_macros.h | 9 | ||||
-rw-r--r-- | libpam/pam_modutil_cleanup.c | 4 | ||||
-rw-r--r-- | libpam/pam_modutil_getgrgid.c | 4 | ||||
-rw-r--r-- | libpam/pam_modutil_getgrnam.c | 4 | ||||
-rw-r--r-- | libpam/pam_modutil_getpwnam.c | 4 | ||||
-rw-r--r-- | libpam/pam_modutil_getpwuid.c | 4 | ||||
-rw-r--r-- | libpam/pam_modutil_getspnam.c | 4 |
7 files changed, 9 insertions, 24 deletions
diff --git a/libpam/include/security/_pam_macros.h b/libpam/include/security/_pam_macros.h index 8044e451..e36f4023 100644 --- a/libpam/include/security/_pam_macros.h +++ b/libpam/include/security/_pam_macros.h @@ -44,10 +44,8 @@ do { \ #define _pam_drop(X) \ do { \ - if (X) { \ - free(X); \ - X=NULL; \ - } \ + free(X); \ + X=NULL; \ } while (0) /* @@ -64,8 +62,7 @@ do { \ free(reply[reply_i].resp); \ } \ } \ - if (reply) \ - free(reply); \ + free(reply); \ } while (0) /* some debugging code */ diff --git a/libpam/pam_modutil_cleanup.c b/libpam/pam_modutil_cleanup.c index 8224ce67..2077cbd7 100644 --- a/libpam/pam_modutil_cleanup.c +++ b/libpam/pam_modutil_cleanup.c @@ -12,8 +12,6 @@ void pam_modutil_cleanup (pam_handle_t *pamh UNUSED, void *data, int error_status UNUSED) { - if (data) { /* junk it */ - (void) free(data); - } + free(data); } diff --git a/libpam/pam_modutil_getgrgid.c b/libpam/pam_modutil_getgrgid.c index 93a59633..fd495105 100644 --- a/libpam/pam_modutil_getgrgid.c +++ b/libpam/pam_modutil_getgrgid.c @@ -54,9 +54,7 @@ pam_modutil_getgrgid(pam_handle_t *pamh, gid_t gid) D(("out of memory")); /* no memory for the user - so delete the memory */ - if (buffer) { - free(buffer); - } + free(buffer); return NULL; } buffer = new_buffer; diff --git a/libpam/pam_modutil_getgrnam.c b/libpam/pam_modutil_getgrnam.c index f5bc52ee..c7dd175c 100644 --- a/libpam/pam_modutil_getgrnam.c +++ b/libpam/pam_modutil_getgrnam.c @@ -44,9 +44,7 @@ pam_modutil_getgrnam(pam_handle_t *pamh, const char *group) D(("out of memory")); /* no memory for the group - so delete the memory */ - if (buffer) { - free(buffer); - } + free(buffer); return NULL; } buffer = new_buffer; diff --git a/libpam/pam_modutil_getpwnam.c b/libpam/pam_modutil_getpwnam.c index 012c9ec8..9c96150b 100644 --- a/libpam/pam_modutil_getpwnam.c +++ b/libpam/pam_modutil_getpwnam.c @@ -44,9 +44,7 @@ pam_modutil_getpwnam(pam_handle_t *pamh, const char *user) D(("out of memory")); /* no memory for the user - so delete the memory */ - if (buffer) { - free(buffer); - } + free(buffer); return NULL; } buffer = new_buffer; diff --git a/libpam/pam_modutil_getpwuid.c b/libpam/pam_modutil_getpwuid.c index cdd196ee..671fdf23 100644 --- a/libpam/pam_modutil_getpwuid.c +++ b/libpam/pam_modutil_getpwuid.c @@ -54,9 +54,7 @@ pam_modutil_getpwuid(pam_handle_t *pamh, uid_t uid) D(("out of memory")); /* no memory for the user - so delete the memory */ - if (buffer) { - free(buffer); - } + free(buffer); return NULL; } buffer = new_buffer; diff --git a/libpam/pam_modutil_getspnam.c b/libpam/pam_modutil_getspnam.c index 2673668c..8b48db90 100644 --- a/libpam/pam_modutil_getspnam.c +++ b/libpam/pam_modutil_getspnam.c @@ -44,9 +44,7 @@ pam_modutil_getspnam(pam_handle_t *pamh, const char *user) D(("out of memory")); /* no memory for the user - so delete the memory */ - if (buffer) { - free(buffer); - } + free(buffer); return NULL; } buffer = new_buffer; |