r12161: Fix a memleak and do the -O1 janitor :-)
authorVolker Lendecke <vlendec@samba.org>
Sat, 10 Dec 2005 09:18:03 +0000 (09:18 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:47:16 +0000 (13:47 -0500)
(This used to be commit 82d87d62614a33ec9d2ed20e63d80a7af64e8678)

source4/dsdb/samdb/samdb.c
source4/libcli/security/sddl.c

index 5e2fa94722c235224e7eef0b13326d956c43d50f..18e482c9d3942f22edb43177ad4790c2511bd35f 100644 (file)
@@ -1004,7 +1004,7 @@ const struct dom_sid *samdb_domain_sid(struct ldb_context *ldb)
        const char *attrs[] = { "rootDomainNamingContext", NULL };
        int ret;
        struct ldb_result *res = NULL;
-       TALLOC_CTX *tmp_ctx = talloc_new(ldb);
+       TALLOC_CTX *tmp_ctx;
        struct dom_sid *domain_sid;
        const char *basedn_s;
        struct ldb_dn *basedn;
@@ -1015,6 +1015,11 @@ const struct dom_sid *samdb_domain_sid(struct ldb_context *ldb)
                return domain_sid;
        }
 
+       tmp_ctx = talloc_new(ldb);
+       if (tmp_ctx == NULL) {
+               goto failed;
+       }
+
        basedn = ldb_dn_explode(tmp_ctx, "");
        if (basedn == NULL) {
                goto failed;
index 7d7fe856cd26ee41afbd23918f5c93a038b973c9..83dfeed5ac961827e7f4e6e47cec69ef0b7918dc 100644 (file)
@@ -448,12 +448,16 @@ static char *sddl_encode_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
 static char *sddl_encode_ace(TALLOC_CTX *mem_ctx, const struct security_ace *ace,
                             const struct dom_sid *domain_sid)
 {
-       char *sddl;
+       char *sddl = NULL;
        TALLOC_CTX *tmp_ctx;
        const char *s_type="", *s_flags="", *s_mask="", 
                *s_object="", *s_iobject="", *s_trustee="";
 
        tmp_ctx = talloc_new(mem_ctx);
+       if (tmp_ctx == NULL) {
+               DEBUG(0, ("talloc_new failed\n"));
+               return NULL;
+       }
 
        s_type = sddl_flags_to_string(tmp_ctx, ace_types, ace->type, True);
        if (s_type == NULL) goto failed;