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-print.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-print.c')
-rw-r--r--src/interfaces/libpq/fe-print.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c
index 82fc592f068..783cd9b756f 100644
--- a/src/interfaces/libpq/fe-print.c
+++ b/src/interfaces/libpq/fe-print.c
@@ -303,26 +303,19 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
fputs("</table>\n", fout);
exit:
- if (fieldMax)
- free(fieldMax);
- if (fieldNotNum)
- free(fieldNotNum);
- if (border)
- free(border);
+ free(fieldMax);
+ free(fieldNotNum);
+ free(border);
if (fields)
{
/* if calloc succeeded, this shouldn't overflow size_t */
size_t numfields = ((size_t) nTups + 1) * (size_t) nFields;
while (numfields-- > 0)
- {
- if (fields[numfields])
- free(fields[numfields]);
- }
+ free(fields[numfields]);
free(fields);
}
- if (fieldNames)
- free((void *) fieldNames);
+ free(fieldNames);
if (usePipe)
{
#ifdef WIN32
@@ -679,8 +672,7 @@ PQdisplayTuples(const PGresult *res,
fflush(fp);
- if (fLength)
- free(fLength);
+ free(fLength);
}
@@ -763,8 +755,7 @@ PQprintTuples(const PGresult *res,
}
}
- if (tborder)
- free(tborder);
+ free(tborder);
}