rpcrt4: Fix the error handling in RpcBindingSetAuthInfoA/W when RpcAuthInfo_Create fails.

Don't release the old auth info until we successfully have a new auth 
info and return failure to the caller if RpcAuthInfo_Create fails.
This commit is contained in:
Rob Shearman 2008-01-23 16:32:45 +00:00 committed by Alexandre Julliard
parent 5819b90f95
commit fef5ce52ce
1 changed files with 18 additions and 10 deletions

View File

@ -1421,13 +1421,17 @@ RpcBindingSetAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName,
FreeContextBuffer(packages);
if (r == ERROR_SUCCESS)
{
if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo);
bind->AuthInfo = NULL;
RpcAuthInfo *new_auth_info;
r = RpcAuthInfo_Create(AuthnLevel, AuthnSvc, cred, exp, cbMaxToken,
AuthIdentity, &bind->AuthInfo);
if (r != RPC_S_OK)
AuthIdentity, &new_auth_info);
if (r == RPC_S_OK)
{
if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo);
bind->AuthInfo = new_auth_info;
}
else
FreeCredentialsHandle(&cred);
return RPC_S_OK;
return r;
}
else
{
@ -1537,13 +1541,17 @@ RpcBindingSetAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName,
FreeContextBuffer(packages);
if (r == ERROR_SUCCESS)
{
if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo);
bind->AuthInfo = NULL;
RpcAuthInfo *new_auth_info;
r = RpcAuthInfo_Create(AuthnLevel, AuthnSvc, cred, exp, cbMaxToken,
AuthIdentity, &bind->AuthInfo);
if (r != RPC_S_OK)
AuthIdentity, &new_auth_info);
if (r == RPC_S_OK)
{
if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo);
bind->AuthInfo = new_auth_info;
}
else
FreeCredentialsHandle(&cred);
return RPC_S_OK;
return r;
}
else
{