summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2013-10-09 15:21:48 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-10-17 13:49:49 +0200
commitfcfc0415a4772330af7aa91eeffeda6ca4bea64d (patch)
treec594819bdf2a65c1c892f34d836d22bfef9f1cb5 /src/lib
parent810e8dfb1523362a0e6ed5a3a218722be97f9607 (diff)
downloadsssd-fcfc0415a4772330af7aa91eeffeda6ca4bea64d.tar.gz
sssd-fcfc0415a4772330af7aa91eeffeda6ca4bea64d.tar.xz
sssd-fcfc0415a4772330af7aa91eeffeda6ca4bea64d.zip
idmap: fix a memory leak if a collision is detected
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/idmap/sss_idmap.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/idmap/sss_idmap.c b/src/lib/idmap/sss_idmap.c
index 45797f227..89c55fc95 100644
--- a/src/lib/idmap/sss_idmap.c
+++ b/src/lib/idmap/sss_idmap.c
@@ -432,24 +432,28 @@ enum idmap_error_code sss_idmap_add_domain_ex(struct sss_idmap_ctx *ctx,
dom->name = idmap_strdup(ctx, domain_name);
if (dom->name == NULL) {
+ err = IDMAP_OUT_OF_MEMORY;
goto fail;
}
if (domain_sid != NULL) {
dom->sid = idmap_strdup(ctx, domain_sid);
if (dom->sid == NULL) {
+ err = IDMAP_OUT_OF_MEMORY;
goto fail;
}
}
dom->range = idmap_range_dup(ctx, range);
if (dom->range == NULL) {
+ err = IDMAP_OUT_OF_MEMORY;
goto fail;
}
if (range_id != NULL) {
dom->range_id = idmap_strdup(ctx, range_id);
if (dom->range_id == NULL) {
+ err = IDMAP_OUT_OF_MEMORY;
goto fail;
}
}
@@ -459,8 +463,7 @@ enum idmap_error_code sss_idmap_add_domain_ex(struct sss_idmap_ctx *ctx,
err = dom_check_collision(ctx->idmap_domain_info, dom);
if (err != IDMAP_SUCCESS) {
- ctx->free_func(dom, ctx->alloc_pvt);
- return err;
+ goto fail;
}
dom->next = ctx->idmap_domain_info;
@@ -469,11 +472,9 @@ enum idmap_error_code sss_idmap_add_domain_ex(struct sss_idmap_ctx *ctx,
return IDMAP_SUCCESS;
fail:
- ctx->free_func(dom->sid, ctx->alloc_pvt);
- ctx->free_func(dom->name, ctx->alloc_pvt);
- ctx->free_func(dom, ctx->alloc_pvt);
+ sss_idmap_free_domain(ctx, dom);
- return IDMAP_OUT_OF_MEMORY;
+ return err;
}
enum idmap_error_code sss_idmap_add_domain(struct sss_idmap_ctx *ctx,