[SSSD] [PATCH] Allocate on top of a talloc context, not NULL

Jakub Hrozek jhrozek at redhat.com
Wed Aug 8 09:08:22 UTC 2012


The attached patch fixes a rather embarrassing memory leak in
create_ccache_dir_head.
-------------- next part --------------
>From 0139f97af6fee3f53233a78806ddb0b1cf97273a Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Mon, 6 Aug 2012 21:33:35 +0200
Subject: [PATCH] Allocate on top of a talloc context, not NULL

---
 src/providers/krb5/krb5_utils.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/providers/krb5/krb5_utils.c b/src/providers/krb5/krb5_utils.c
index f92a2cc6d4c1ef7167a2d4f05117e42fca579046..8b15fc35dd172179713eac53fc2d4aa20f229d28 100644
--- a/src/providers/krb5/krb5_utils.c
+++ b/src/providers/krb5/krb5_utils.c
@@ -547,6 +547,9 @@ create_ccache_dir_head(const char *parent, pcre *illegal_re,
     char *end;
     errno_t ret;
 
+    tmp_ctx = talloc_new(NULL);
+    if (!tmp_ctx) return ENOMEM;
+
     ccdirname = talloc_strdup(tmp_ctx, parent);
     if (ccdirname == NULL) {
         DEBUG(SSSDBG_CRIT_FAILURE, ("talloc_strdup failed.\n"));
-- 
1.7.11.2



More information about the sssd-devel mailing list