From da6e845672e9ab68a32946a734c4ba8ce2cc1fc0 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 3 May 2011 17:51:30 +0200 Subject: Do not leak pcre context --- src/providers/krb5/krb5_init.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/providers/krb5/krb5_init.c b/src/providers/krb5/krb5_init.c index 525ba4dfc..6176dd187 100644 --- a/src/providers/krb5/krb5_init.c +++ b/src/providers/krb5/krb5_init.c @@ -42,6 +42,17 @@ struct bet_ops krb5_auth_ops = { .finalize = NULL, }; +int krb5_ctx_re_destructor(void *memctx) +{ + struct krb5_ctx *ctx = (struct krb5_ctx *) memctx; + + if (ctx->illegal_path_re) { + pcre_free(ctx->illegal_path_re); + ctx->illegal_path_re = NULL; + } + return 0; +} + int sssm_krb5_auth_init(struct be_ctx *bectx, struct bet_ops **ops, void **pvt_auth_data) @@ -183,6 +194,7 @@ int sssm_krb5_auth_init(struct be_ctx *bectx, ret = EFAULT; goto fail; } + talloc_set_destructor((TALLOC_CTX *) ctx, krb5_ctx_re_destructor); *ops = &krb5_auth_ops; *pvt_auth_data = ctx; -- cgit