From ced7fa157d3f298c2ddcd3ad21bfa9cbc2b38d4f 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 . (cherry picked from commit d239853d024ca8fdc9fd719c75025020611ff5a1) --- ChangeLog | 7 +++++++ lib/vasnprintf.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 15db3c89c..66e5c73b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 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. * modules/socketlib (Files): Add m4/sys_socket_h.m4. Needed for gl_PREREQ_SYS_H_WINSOCK2. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 388ab0dbe..59ea01cc7 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.11.0