Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2022-06-16 19:50:56 +0000
committerPeter Eisentraut2022-07-03 09:47:15 +0000
commit02c408e21a6e78ff246ea7a1beb4669634fa9c4c (patch)
tree7e4cf03f3de7e32af266b739e12c6600d871ed45 /src/interfaces/libpq/fe-auth-scram.c
parent098c703d308fa88dc9e3f9f623ca023ce4717794 (diff)
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-scram.c')
-rw-r--r--src/interfaces/libpq/fe-auth-scram.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/interfaces/libpq/fe-auth-scram.c b/src/interfaces/libpq/fe-auth-scram.c
index e6162007041..5012806fa5e 100644
--- a/src/interfaces/libpq/fe-auth-scram.c
+++ b/src/interfaces/libpq/fe-auth-scram.c
@@ -174,30 +174,21 @@ scram_free(void *opaq)
{
fe_scram_state *state = (fe_scram_state *) opaq;
- if (state->password)
- free(state->password);
- if (state->sasl_mechanism)
- free(state->sasl_mechanism);
+ free(state->password);
+ free(state->sasl_mechanism);
/* client messages */
- if (state->client_nonce)
- free(state->client_nonce);
- if (state->client_first_message_bare)
- free(state->client_first_message_bare);
- if (state->client_final_message_without_proof)
- free(state->client_final_message_without_proof);
+ free(state->client_nonce);
+ free(state->client_first_message_bare);
+ free(state->client_final_message_without_proof);
/* first message from server */
- if (state->server_first_message)
- free(state->server_first_message);
- if (state->salt)
- free(state->salt);
- if (state->nonce)
- free(state->nonce);
+ free(state->server_first_message);
+ free(state->salt);
+ free(state->nonce);
/* final message from server */
- if (state->server_final_message)
- free(state->server_final_message);
+ free(state->server_final_message);
free(state);
}
@@ -941,8 +932,7 @@ pg_fe_scram_build_secret(const char *password, const char **errstr)
if (!pg_strong_random(saltbuf, SCRAM_DEFAULT_SALT_LEN))
{
*errstr = _("failed to generate random salt");
- if (prep_password)
- free(prep_password);
+ free(prep_password);
return NULL;
}
@@ -950,8 +940,7 @@ pg_fe_scram_build_secret(const char *password, const char **errstr)
SCRAM_DEFAULT_ITERATIONS, password,
errstr);
- if (prep_password)
- free(prep_password);
+ free(prep_password);
return result;
}