git: 162dfe766b2a - main - pfctl: Remove NULL-checks before free(). ok tb@
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 16 Apr 2025 18:02:50 UTC
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=162dfe766b2a62fb875a47796ffb032242ff5124
commit 162dfe766b2a62fb875a47796ffb032242ff5124
Author: Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-04-15 15:23:01 +0000
Commit: Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-04-16 14:23:47 +0000
pfctl: Remove NULL-checks before free(). ok tb@
Obtained from: OpenBSD, mmcc <mmcc@openbsd.org>, 5ce950dec1
Sponsored by: Rubicon Communications, LLC ("Netgate")
---
sbin/pfctl/pfctl_osfp.c | 30 ++++++++++--------------------
sbin/pfctl/pfctl_radix.c | 3 +--
2 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/sbin/pfctl/pfctl_osfp.c b/sbin/pfctl/pfctl_osfp.c
index 649c1e8a2c3b..3a94c2e8c81b 100644
--- a/sbin/pfctl/pfctl_osfp.c
+++ b/sbin/pfctl/pfctl_osfp.c
@@ -112,16 +112,11 @@ pfctl_file_fingerprints(int dev, int opts, const char *fp_filename)
while ((line = fgetln(in, &len)) != NULL) {
lineno++;
- if (class)
- free(class);
- if (version)
- free(version);
- if (subtype)
- free(subtype);
- if (desc)
- free(desc);
- if (tcpopts)
- free(tcpopts);
+ free(class);
+ free(version);
+ free(subtype);
+ free(desc);
+ free(tcpopts);
class = version = subtype = desc = tcpopts = NULL;
memset(&fp, 0, sizeof(fp));
@@ -250,16 +245,11 @@ pfctl_file_fingerprints(int dev, int opts, const char *fp_filename)
add_fingerprint(dev, opts, &fp);
}
- if (class)
- free(class);
- if (version)
- free(version);
- if (subtype)
- free(subtype);
- if (desc)
- free(desc);
- if (tcpopts)
- free(tcpopts);
+ free(class);
+ free(version);
+ free(subtype);
+ free(desc);
+ free(tcpopts);
fclose(in);
diff --git a/sbin/pfctl/pfctl_radix.c b/sbin/pfctl/pfctl_radix.c
index 1d1918e29f44..e4659a30b234 100644
--- a/sbin/pfctl/pfctl_radix.c
+++ b/sbin/pfctl/pfctl_radix.c
@@ -406,8 +406,7 @@ pfr_buf_clear(struct pfr_buffer *b)
{
if (b == NULL)
return;
- if (b->pfrb_caddr != NULL)
- free(b->pfrb_caddr);
+ free(b->pfrb_caddr);
b->pfrb_caddr = NULL;
b->pfrb_size = b->pfrb_msize = 0;
}