diff options
author | Matthieu Patou <mat@matws.net> | 2010-08-15 18:31:28 +0400 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2010-10-03 01:15:04 +0000 |
commit | ab6e3fce040f9ad27cbce44e9038a24f15b601c8 (patch) | |
tree | ab99a431c9610927b5d0d26335d2712b509fd6dc /source4/heimdal/lib/krb5/error_string.c | |
parent | 197a1514d62494cc8b862d169c841a26e04b8925 (diff) | |
download | samba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.tar.gz samba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.tar.bz2 samba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.zip |
s4:heimdal: import lorikeet-heimdal-201009250123 (commit 42cabfb5b683dbcb97d583c397b897507689e382)
I based this on Matthieu's import of lorikeet-heimdal, and then
updated it to this commit.
Andrew Bartlett
Diffstat (limited to 'source4/heimdal/lib/krb5/error_string.c')
-rw-r--r-- | source4/heimdal/lib/krb5/error_string.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/source4/heimdal/lib/krb5/error_string.c b/source4/heimdal/lib/krb5/error_string.c index adab6f5e84..237d346f4d 100644 --- a/source4/heimdal/lib/krb5/error_string.c +++ b/source4/heimdal/lib/krb5/error_string.c @@ -96,11 +96,17 @@ krb5_vset_error_message (krb5_context context, krb5_error_code ret, const char *fmt, va_list args) __attribute__ ((format (printf, 3, 0))) { + int r; - krb5_clear_error_message(context); HEIMDAL_MUTEX_lock(context->mutex); + if (context->error_string) { + free(context->error_string); + context->error_string = NULL; + } context->error_code = ret; - vasprintf(&context->error_string, fmt, args); + r = vasprintf(&context->error_string, fmt, args); + if (r < 0) + context->error_string = NULL; HEIMDAL_MUTEX_unlock(context->mutex); } @@ -144,19 +150,22 @@ krb5_vprepend_error_message(krb5_context context, krb5_error_code ret, const char *fmt, va_list args) __attribute__ ((format (printf, 3, 0))) { - char *str, *str2; + char *str = NULL, *str2 = NULL; HEIMDAL_MUTEX_lock(context->mutex); if (context->error_code != ret) { HEIMDAL_MUTEX_unlock(context->mutex); return; } - vasprintf(&str, fmt, args); + if (vasprintf(&str, fmt, args) < 0 || str == NULL) { + HEIMDAL_MUTEX_unlock(context->mutex); + return; + } if (context->error_string) { int e; e = asprintf(&str2, "%s: %s", str, context->error_string); free(context->error_string); - if (e < 0) + if (e < 0 || str2 == NULL) context->error_string = NULL; else context->error_string = str2; @@ -241,7 +250,7 @@ krb5_get_error_message(krb5_context context, krb5_error_code code) return strdup(msg); } - if (asprintf(&str, "<unknown error: %d>", (int)code) == -1) + if (asprintf(&str, "<unknown error: %d>", (int)code) == -1 || str == NULL) return NULL; return str; |