summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-08-27 22:15:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:34:41 -0500
commitd91a5808f07750cb70759d8588b58557184f790a (patch)
tree152864927c3c01a36f91d59b5617324b965ff5cc
parente1269bafe8449f2417d7c666bf0f95af5d7a005f (diff)
downloadsamba-d91a5808f07750cb70759d8588b58557184f790a.tar.gz
samba-d91a5808f07750cb70759d8588b58557184f790a.tar.bz2
samba-d91a5808f07750cb70759d8588b58557184f790a.zip
r9693: Move the smb_krb5_context setup code to use the new pattern of
tmp_ctx, then steal at the last moment, on success. andrew Bartlett (This used to be commit c7a44518ad9acaf5708169e07aa03eae52262773)
-rw-r--r--source4/auth/kerberos/clikrb5.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/source4/auth/kerberos/clikrb5.c b/source4/auth/kerberos/clikrb5.c
index 7a43498773..3f4f821958 100644
--- a/source4/auth/kerberos/clikrb5.c
+++ b/source4/auth/kerberos/clikrb5.c
@@ -423,8 +423,8 @@ static void smb_krb5_debug_wrapper(const char *timestr, const char *msg, void *p
initialize_krb5_error_table();
- *smb_krb5_context = talloc(parent_ctx, struct smb_krb5_context);
- tmp_ctx = talloc_new(*smb_krb5_context);
+ tmp_ctx = talloc_new(parent_ctx);
+ *smb_krb5_context = talloc(tmp_ctx, struct smb_krb5_context);
if (!*smb_krb5_context || !tmp_ctx) {
talloc_free(*smb_krb5_context);
@@ -445,13 +445,14 @@ static void smb_krb5_debug_wrapper(const char *timestr, const char *msg, void *p
char *upper_realm = strupper_talloc(tmp_ctx, lp_realm());
if (!upper_realm) {
DEBUG(1,("gensec_krb5_start: could not uppercase realm: %s\n", lp_realm()));
+ talloc_free(tmp_ctx);
return ENOMEM;
}
ret = krb5_set_default_realm((*smb_krb5_context)->krb5_context, lp_realm());
if (ret) {
DEBUG(1,("krb5_set_default_realm failed (%s)\n",
smb_get_krb5_error_message((*smb_krb5_context)->krb5_context, ret, tmp_ctx)));
- talloc_free(*smb_krb5_context);
+ talloc_free(tmp_ctx);
return ret;
}
}
@@ -463,7 +464,7 @@ static void smb_krb5_debug_wrapper(const char *timestr, const char *msg, void *p
if (ret) {
DEBUG(1,("krb5_initlog failed (%s)\n",
smb_get_krb5_error_message((*smb_krb5_context)->krb5_context, ret, tmp_ctx)));
- talloc_free(*smb_krb5_context);
+ talloc_free(tmp_ctx);
return ret;
}
@@ -474,12 +475,13 @@ static void smb_krb5_debug_wrapper(const char *timestr, const char *msg, void *p
if (ret) {
DEBUG(1,("krb5_addlog_func failed (%s)\n",
smb_get_krb5_error_message((*smb_krb5_context)->krb5_context, ret, tmp_ctx)));
- talloc_free(*smb_krb5_context);
+ talloc_free(tmp_ctx);
return ret;
}
krb5_set_warn_dest((*smb_krb5_context)->krb5_context, (*smb_krb5_context)->logf);
#endif
+ talloc_steal(parent_ctx, *smb_krb5_context);
talloc_free(tmp_ctx);
return 0;
}