Patchwork [6/9] nsdb: don't leak a read buffer upon certfile open failure

login
register
mail settings
Submitter Jim Meyering
Date Dec. 1, 2011, 3:58 p.m.
Message ID <1322755106-8171-7-git-send-email-jim@meyering.net>
Download mbox | patch
Permalink /patch/128716/
State Superseded
Headers show

Comments

Jim Meyering - Dec. 1, 2011, 3:58 p.m.
From: Jim Meyering <meyering@redhat.com>

* src/libnsdb/nsdb.c (nsdb_read_certfile): Free "buf" also
on the failed-open path.  Spotted by coverity.

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
 src/libnsdb/nsdb.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Patch

diff --git a/src/libnsdb/nsdb.c b/src/libnsdb/nsdb.c
index c81f228..02c0588 100644
--- a/src/libnsdb/nsdb.c
+++ b/src/libnsdb/nsdb.c
@@ -524,6 +524,7 @@  nsdb_read_certfile(const char *pathname, char **certdata,
 	if (fd == -1) {
 		xlog(D_GENERAL, "%s: Failed to open %s: %m",
 			__func__, pathname);
+		free(buf);
 		goto out;
 	}