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:45:44 +0200
commit222f2484ea37c8bd434184ccd38160fb58c8087f (patch)
treedb789b66b3ba9a7b7352b56d13348acae2e3ccd9 /src/lib
parentcff4a89e38078337d74aa558f0e628d5756b3bba (diff)
downloadsssd-222f2484ea37c8bd434184ccd38160fb58c8087f.tar.gz
sssd-222f2484ea37c8bd434184ccd38160fb58c8087f.tar.xz
sssd-222f2484ea37c8bd434184ccd38160fb58c8087f.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,