aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-auth.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2022-06-16 21:50:56 +0200
committerPeter Eisentraut <peter@eisentraut.org>2022-07-03 11:47:15 +0200
commit02c408e21a6e78ff246ea7a1beb4669634fa9c4c (patch)
tree7e4cf03f3de7e32af266b739e12c6600d871ed45 /src/interfaces/libpq/fe-auth.c
parent098c703d308fa88dc9e3f9f623ca023ce4717794 (diff)
downloadpostgresql-02c408e21a6e78ff246ea7a1beb4669634fa9c4c.tar.gz
postgresql-02c408e21a6e78ff246ea7a1beb4669634fa9c4c.zip
Remove redundant null pointer checks before free()
Per applicable standards, free() with a null pointer is a no-op. Systems that don't observe that are ancient and no longer relevant. Some PostgreSQL code already required this behavior, so this change does not introduce any new requirements, just makes the code more consistent. Discussion: https://www.postgresql.org/message-id/flat/dac5d2d0-98f5-94d9-8e69-46da2413593d%40enterprisedb.com
Diffstat (limited to 'src/interfaces/libpq/fe-auth.c')
-rw-r--r--src/interfaces/libpq/fe-auth.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index 0a072a36dc2..49a1c626f64 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -107,8 +107,7 @@ pg_GSS_continue(PGconn *conn, int payloadlen)
NULL,
NULL);
- if (ginbuf.value)
- free(ginbuf.value);
+ free(ginbuf.value);
if (goutbuf.length != 0)
{
@@ -270,8 +269,7 @@ pg_SSPI_continue(PGconn *conn, int payloadlen)
NULL);
/* we don't need the input anymore */
- if (inputbuf)
- free(inputbuf);
+ free(inputbuf);
if (r != SEC_E_OK && r != SEC_I_CONTINUE_NEEDED)
{
@@ -604,21 +602,18 @@ pg_SASL_init(PGconn *conn, int payloadlen)
goto error;
termPQExpBuffer(&mechanism_buf);
- if (initialresponse)
- free(initialresponse);
+ free(initialresponse);
return STATUS_OK;
error:
termPQExpBuffer(&mechanism_buf);
- if (initialresponse)
- free(initialresponse);
+ free(initialresponse);
return STATUS_ERROR;
oom_error:
termPQExpBuffer(&mechanism_buf);
- if (initialresponse)
- free(initialresponse);
+ free(initialresponse);
appendPQExpBufferStr(&conn->errorMessage,
libpq_gettext("out of memory\n"));
return STATUS_ERROR;
@@ -831,8 +826,7 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
return STATUS_ERROR;
}
ret = pqPacketSend(conn, 'p', pwd_to_send, strlen(pwd_to_send) + 1);
- if (crypt_pwd)
- free(crypt_pwd);
+ free(crypt_pwd);
return ret;
}