diff options
author | Simon Josefsson <simon@josefsson.org> | 2010-05-28 08:47:14 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2010-05-28 08:50:07 +0200 |
commit | e4b0fe0763c0e87c87e87baf30aa7039e94c20b0 (patch) | |
tree | 8e9336525ec654b47a4ebdffbb391bcfa7ac7c57 /gl/vasnprintf.c | |
parent | 79b2b7f8603242b8a2af0d2244f049a5db50e242 (diff) | |
download | gnutls-e4b0fe0763c0e87c87e87baf30aa7039e94c20b0.tar.gz |
Update gnulib files, use valgrind-tests module, fix syntax-check problems.
Diffstat (limited to 'gl/vasnprintf.c')
-rw-r--r-- | gl/vasnprintf.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c index 1ca8d534a0..e618901ba2 100644 --- a/gl/vasnprintf.c +++ b/gl/vasnprintf.c @@ -2889,8 +2889,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, length += n; } } - } # endif + } #endif #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL else if ((dp->conversion == 'a' || dp->conversion == 'A') @@ -4953,6 +4953,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } #endif + errno = 0; switch (type) { case TYPE_SCHAR: @@ -5147,15 +5148,21 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* Attempt to handle failure. */ if (count < 0) { + /* SNPRINTF or sprintf failed. Save and use the errno + that it has set, if any. */ + int saved_errno = errno; + if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = - (dp->conversion == 'c' || dp->conversion == 's' - ? EILSEQ - : EINVAL); + (saved_errno != 0 + ? saved_errno + : (dp->conversion == 'c' || dp->conversion == 's' + ? EILSEQ + : EINVAL)); return NULL; } @@ -5491,6 +5498,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, length += count; break; } +#undef pad_ourselves +#undef prec_ourselves } } } |