Make krb5_get_error_string return an allocated string to make the
function indempotent. From Zeqing (Fred) Xia. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22142 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -86,14 +86,26 @@ krb5_vset_error_string(krb5_context context, const char *fmt, va_list args)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the error message in context. On error or no error string,
|
||||||
|
* the function returns NULL.
|
||||||
|
*
|
||||||
|
* @param context Kerberos 5 context
|
||||||
|
*
|
||||||
|
* @return an error string, needs to be freed with
|
||||||
|
* krb5_free_error_string(). The functions return NULL on error.
|
||||||
|
*
|
||||||
|
* @ingroup krb5_error
|
||||||
|
*/
|
||||||
|
|
||||||
char * KRB5_LIB_FUNCTION
|
char * KRB5_LIB_FUNCTION
|
||||||
krb5_get_error_string(krb5_context context)
|
krb5_get_error_string(krb5_context context)
|
||||||
{
|
{
|
||||||
char *ret;
|
char *ret = NULL;
|
||||||
|
|
||||||
HEIMDAL_MUTEX_lock(context->mutex);
|
HEIMDAL_MUTEX_lock(context->mutex);
|
||||||
ret = context->error_string;
|
if (context->error_string)
|
||||||
context->error_string = NULL;
|
ret = strdup(context->error_string);
|
||||||
HEIMDAL_MUTEX_unlock(context->mutex);
|
HEIMDAL_MUTEX_unlock(context->mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -115,8 +127,8 @@ krb5_have_error_string(krb5_context context)
|
|||||||
* @param context Kerberos 5 context
|
* @param context Kerberos 5 context
|
||||||
* @param code Error code related to the error
|
* @param code Error code related to the error
|
||||||
*
|
*
|
||||||
* @return an error string, needs to be freed with krb5_xfree(). The
|
* @return an error string, needs to be freed with
|
||||||
* functions return NULL on error.
|
* krb5_free_error_string(). The functions return NULL on error.
|
||||||
*
|
*
|
||||||
* @ingroup krb5_error
|
* @ingroup krb5_error
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user