From 098c703d308fa88dc9e3f9f623ca023ce4717794 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 17 Jun 2022 11:51:38 +0200 Subject: Remove redundant null pointer checks before pg_free() These are especially useless because the whole point of pg_free() was to do that very check before calling free(). pg_free() could be removed altogether, but I'm keeping it here to keep the API consistent. Discussion: https://www.postgresql.org/message-id/flat/dac5d2d0-98f5-94d9-8e69-46da2413593d%40enterprisedb.com --- src/bin/psql/variables.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/bin/psql/variables.c') diff --git a/src/bin/psql/variables.c b/src/bin/psql/variables.c index 47c58d2be9d..5cc4bc0cb78 100644 --- a/src/bin/psql/variables.c +++ b/src/bin/psql/variables.c @@ -255,8 +255,7 @@ SetVariable(VariableSpace space, const char *name, const char *value) if (confirmed) { - if (current->value) - pg_free(current->value); + pg_free(current->value); current->value = new_value; /* @@ -272,7 +271,7 @@ SetVariable(VariableSpace space, const char *name, const char *value) free(current); } } - else if (new_value) + else pg_free(new_value); /* current->value is left unchanged */ return confirmed; -- cgit v1.2.3