idmap4: Fix error path memleaks in idmap_init
authorVolker Lendecke <vl@samba.org>
Tue, 27 Dec 2016 12:21:09 +0000 (12:21 +0000)
committerUri Simchoni <uri@samba.org>
Wed, 28 Dec 2016 19:17:12 +0000 (20:17 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
source4/winbind/idmap.c

index 578a7c303c9c159a083de7209d975a1d10ee91a5..6f701f0462101d92a65c3847a72c59462b593fd0 100644 (file)
@@ -171,28 +171,31 @@ struct idmap_context *idmap_init(TALLOC_CTX *mem_ctx,
                                              system_session(lp_ctx),
                                              NULL, 0);
        if (idmap_ctx->ldb_ctx == NULL) {
-               return NULL;
+               goto fail;
        }
 
        idmap_ctx->unix_groups_sid = dom_sid_parse_talloc(
                idmap_ctx, "S-1-22-2");
        if (idmap_ctx->unix_groups_sid == NULL) {
-               return NULL;
+               goto fail;
        }
 
        idmap_ctx->unix_users_sid = dom_sid_parse_talloc(
                idmap_ctx, "S-1-22-1");
        if (idmap_ctx->unix_users_sid == NULL) {
-               return NULL;
+               goto fail;
        }
        
        idmap_ctx->samdb = samdb_connect(idmap_ctx, ev_ctx, lp_ctx, system_session(lp_ctx), 0);
        if (idmap_ctx->samdb == NULL) {
                DEBUG(0, ("Failed to load sam.ldb in idmap_init\n"));
-               return NULL;
+               goto fail;
        }
 
        return idmap_ctx;
+fail:
+       TALLOC_FREE(idmap_ctx);
+       return NULL;
 }
 
 /**