Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jun 2025 15:16:15 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: c31621c125ee - main - pfctl: fix memory leak
Message-ID:  <202506271516.55RFGFII049184@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=c31621c125ee4fa60e320781447864ebca5b3173

commit c31621c125ee4fa60e320781447864ebca5b3173
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-06-24 11:43:26 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-06-27 14:55:17 +0000

    pfctl: fix memory leak
    
    Be consistent in warn() and log_warn() usage when
    running out of memory.
    
    Next step, be correct *and* consistent.
    
    ok dennis@ tb@ benno@ schwarze@
    
    Obtained from:  OpenBSD, krw <krw@openbsd.org>, 3c12ada049
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sbin/pfctl/parse.y | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 8afef160b205..41f2d8dc70e7 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -7143,9 +7143,11 @@ pushfile(const char *name, int secret)
 
 	if ((nfile = calloc(1, sizeof(struct file))) == NULL ||
 	    (nfile->name = strdup(name)) == NULL) {
-		if (nfile)
+		if (nfile) {
+			warn("strdup");
 			free(nfile);
-		warn("malloc");
+		} else
+			warn("calloc");
 		return (NULL);
 	}
 	if (TAILQ_FIRST(&files) == NULL && strcmp(nfile->name, "-") == 0) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202506271516.55RFGFII049184>