Patchwork [v2,7/8] libsi: don't leak a struct srvinfo upon failed strdup

login
register
mail settings
Submitter Jim Meyering
Date Dec. 1, 2011, 12:27 p.m.
Message ID <1322742439-2171-8-git-send-email-jim@meyering.net>
Download mbox | patch
Permalink /patch/128694/
State Superseded
Headers show

Comments

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

* src/libsi/getsrvinfo.c (getsrvinfo): Free "new".
Spotted by coverity.

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

Patch

diff --git a/src/libsi/getsrvinfo.c b/src/libsi/getsrvinfo.c
index 7a465c7..931847e 100644
--- a/src/libsi/getsrvinfo.c
+++ b/src/libsi/getsrvinfo.c
@@ -289,6 +289,7 @@  getsrvinfo(const char *srvname, const char *domainname, struct srvinfo **si)

 		new->si_target = strdup(exp_dn);
 		if (new->si_target == NULL) {
+			free(new);
 			status = ESI_MEMORY;
 			goto out;
 		}