Patchwork [6/9] libnsdb: don't leak upon LDAP parse failure

login
register
mail settings
Submitter Chuck Lever
Date Dec. 5, 2011, 5:23 p.m.
Message ID <20111205172355.7753.36939.stgit@degas.1015granger.net>
Download mbox | patch
Permalink /patch/129379/
State Accepted
Headers show

Comments

Chuck Lever - Dec. 5, 2011, 5:23 p.m.
From: Jim Meyering <meyering@redhat.com>

* src/libnsdb/fileserver.c (nsdb_resolve_fsn_parse_entry): When we
fail to parse an LDAP entry, free just-allocated new->fl_dn and new.
Spotted by coverity.

Introduced by commit 0520ee72: "Initial commit," (March 29, 2011).

Signed-off-by: Jim Meyering <meyering@redhat.com>
---

 src/libnsdb/fileserver.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Patch

diff --git a/src/libnsdb/fileserver.c b/src/libnsdb/fileserver.c
index a7631e8..b22d83f 100644
--- a/src/libnsdb/fileserver.c
+++ b/src/libnsdb/fileserver.c
@@ -781,6 +781,8 @@  nsdb_resolve_fsn_parse_entry(LDAP *ld, LDAPMessage *entry,
 	if (retval != FEDFS_OK) {
 		xlog(D_CALL, "%s: parsing failed: %s",
 			__func__, nsdb_display_fedfsstatus(retval));
+		free(new->fl_dn);
+		free(new);
 		return retval;
 	}