git: 6880405bf97d - main - cap_mkdb: Fix memory leak
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 27 May 2026 17:02:42 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=6880405bf97df03ffce227d34c2faa99b602a49d
commit 6880405bf97df03ffce227d34c2faa99b602a49d
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-05-27 17:02:12 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-05-27 17:02:12 +0000
cap_mkdb: Fix memory leak
This is not a big deal since it only iterates once before exiting, but
that's no reason to set a bad example.
PR: 195128
MFC after: 1 week
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D57251
---
usr.bin/cap_mkdb/cap_mkdb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/usr.bin/cap_mkdb/cap_mkdb.c b/usr.bin/cap_mkdb/cap_mkdb.c
index 7ee6d2ddd2b3..019dad1ee72e 100644
--- a/usr.bin/cap_mkdb/cap_mkdb.c
+++ b/usr.bin/cap_mkdb/cap_mkdb.c
@@ -117,6 +117,7 @@ main(int argc, char *argv[])
if (capdbp->close(capdbp) < 0)
err(1, "%s", capname);
+ free(capname);
capname = NULL;
exit(0);
}
@@ -151,7 +152,7 @@ db_build(char **ifiles)
data.data = NULL;
key.data = NULL;
- for (reccnt = 0, bplen = 0; (st = cgetnext(&bp, ifiles)) > 0;) {
+ for (reccnt = 0, bplen = 0; (st = cgetnext(&bp, ifiles)) > 0; free(bp)) {
/*
* Allocate enough memory to store record, terminating