summaryrefslogtreecommitdiff
path: root/src/fe_utils
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/fe_utils
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/fe_utils')
-rw-r--r--src/fe_utils/connect_utils.c3
-rw-r--r--src/fe_utils/string_utils.c6
2 files changed, 3 insertions, 6 deletions
diff --git a/src/fe_utils/connect_utils.c b/src/fe_utils/connect_utils.c
index f2e583f9fac..1cc97b72f71 100644
--- a/src/fe_utils/connect_utils.c
+++ b/src/fe_utils/connect_utils.c
@@ -99,8 +99,7 @@ connectDatabase(const ConnParams *cparams, const char *progname,
cparams->prompt_password != TRI_NO)
{
PQfinish(conn);
- if (password)
- free(password);
+ free(password);
password = simple_prompt("Password: ", false);
new_pass = true;
}
diff --git a/src/fe_utils/string_utils.c b/src/fe_utils/string_utils.c
index c3ea4fc1860..f9ea08705af 100644
--- a/src/fe_utils/string_utils.c
+++ b/src/fe_utils/string_utils.c
@@ -810,8 +810,7 @@ appendReloptionsArray(PQExpBuffer buffer, const char *reloptions,
if (!parsePGArray(reloptions, &options, &noptions))
{
- if (options)
- free(options);
+ free(options);
return false;
}
@@ -854,8 +853,7 @@ appendReloptionsArray(PQExpBuffer buffer, const char *reloptions,
appendStringLiteral(buffer, value, encoding, std_strings);
}
- if (options)
- free(options);
+ free(options);
return true;
}