diff options
author | Pavel Reichl <preichl@redhat.com> | 2016-01-22 12:30:23 -0500 |
---|---|---|
committer | Lukas Slebodnik <lslebodn@redhat.com> | 2016-01-28 15:03:48 +0100 |
commit | 5554a2a679f72f19f266d660a5681e3b0c657379 (patch) | |
tree | 5915ce2bad619b0316625498d489e78d56fbe5fc /src/lib | |
parent | 5f2b1986a16a394ecbecd16f82c7265b5b47b546 (diff) | |
download | sssd-5554a2a679f72f19f266d660a5681e3b0c657379.tar.gz sssd-5554a2a679f72f19f266d660a5681e3b0c657379.tar.xz sssd-5554a2a679f72f19f266d660a5681e3b0c657379.zip |
IDMAP: Fix minor memory leak
Reviewed-by: Michal Židek <mzidek@redhat.com>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/idmap/sss_idmap.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/idmap/sss_idmap.c b/src/lib/idmap/sss_idmap.c index 269ef0132..e3e9972b8 100644 --- a/src/lib/idmap/sss_idmap.c +++ b/src/lib/idmap/sss_idmap.c @@ -607,13 +607,13 @@ get_helpers(struct sss_idmap_ctx *ctx, for (int i = 0; i < ctx->idmap_opts.extra_slice_init; i++) { secondary_name = generate_sec_slice_name(ctx, domain_sid, first_rid); if (secondary_name == NULL) { - return IDMAP_OUT_OF_MEMORY; + err = IDMAP_OUT_OF_MEMORY; + goto fail; } err = generate_slice(ctx, secondary_name, first_rid, &slice); if (err != IDMAP_SUCCESS) { - ctx->free_func(secondary_name, ctx->alloc_pvt); - return err; + goto fail; } first_rid += ctx->idmap_opts.rangesize; @@ -631,6 +631,14 @@ get_helpers(struct sss_idmap_ctx *ctx, *_sec_slices = sec_slices; return IDMAP_SUCCESS; + +fail: + ctx->free_func(secondary_name, ctx->alloc_pvt); + + /* Free already generated helpers. */ + free_helpers(ctx, sec_slices, true); + + return err; } enum idmap_error_code sss_idmap_add_domain_ex(struct sss_idmap_ctx *ctx, |