From d239853d024ca8fdc9fd719c75025020611ff5a1 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 15 Oct 2010 02:01:51 +0200 Subject: [PATCH] vasnprintf: Don't set errno to 0. * lib/vasnprintf.c (VASNPRINTF): Save and restore errno around the block that sets it to 0. Reported by Gianluigi Tiesi . --- ChangeLog | 7 +++++++ lib/vasnprintf.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index dc3a8d4299..4e36a0ff99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-10-14 Bruno Haible + + vasnprintf: Don't set errno to 0. + * lib/vasnprintf.c (VASNPRINTF): Save and restore errno around the + block that sets it to 0. + Reported by Gianluigi Tiesi . + 2010-10-14 Bruno Haible socketlib: Fix. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 388ab0dbe3..59ea01cc7e 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -4599,6 +4599,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, TCHAR_T *fbp; unsigned int prefix_count; int prefixes[2] IF_LINT (= { 0 }); + int orig_errno; #if !USE_SNPRINTF size_t tmp_length; TCHAR_T tmpbuf[700]; @@ -4902,6 +4903,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, *(TCHAR_T *) (result + length) = '\0'; #endif + orig_errno = errno; + for (;;) { int count = -1; @@ -5499,6 +5502,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, length += count; break; } + errno = orig_errno; #undef pad_ourselves #undef prec_ourselves } -- 2.30.2