Author: abartlet
Date: 2005-08-27 22:15:29 +0000 (Sat, 27 Aug 2005)
New Revision: 9693

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9693

Log:
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

Modified:
   branches/SAMBA_4_0/source/auth/kerberos/clikrb5.c


Changeset:
Modified: branches/SAMBA_4_0/source/auth/kerberos/clikrb5.c
===================================================================
--- branches/SAMBA_4_0/source/auth/kerberos/clikrb5.c   2005-08-27 21:48:50 UTC 
(rev 9692)
+++ branches/SAMBA_4_0/source/auth/kerberos/clikrb5.c   2005-08-27 22:15:29 UTC 
(rev 9693)
@@ -423,8 +423,8 @@
        
        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 @@
                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 @@
        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 @@
        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;
 }

Reply via email to