[PATCH] libcli: Fix a memleak

Volker Lendecke Volker.Lendecke at SerNet.DE
Mon May 26 14:51:57 MDT 2014


Hi!

Attached find a patch for a (small) memory leak.

Review & push would be appreciated.

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
>From 1d2cc7620e650f4d38bffc874e61cd58f0b14022 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 26 May 2014 20:48:05 +0000
Subject: [PATCH] libcli: Fix a memleak

struct security_ace has a struct dom_sid, not a pointer to it. So we don't have
to talloc it first and then not free it.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 libcli/security/security_descriptor.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libcli/security/security_descriptor.c b/libcli/security/security_descriptor.c
index 574dd4e..96de87f 100644
--- a/libcli/security/security_descriptor.c
+++ b/libcli/security/security_descriptor.c
@@ -564,21 +564,19 @@ struct security_ace *security_ace_create(TALLOC_CTX *mem_ctx,
 					 uint8_t flags)
 
 {
-	struct dom_sid *sid;
 	struct security_ace *ace;
+	bool ret;
 
 	ace = talloc_zero(mem_ctx, struct security_ace);
 	if (ace == NULL) {
 		return NULL;
 	}
 
-	sid = dom_sid_parse_talloc(ace, sid_str);
-	if (sid == NULL) {
+	ret = dom_sid_parse(sid_str, &ace->trustee);
+	if (!ret) {
 		talloc_free(ace);
 		return NULL;
 	}
-
-	ace->trustee = *sid;
 	ace->type = type;
 	ace->access_mask = access_mask;
 	ace->flags = flags;
-- 
1.8.1.2



More information about the samba-technical mailing list