Hi, Gianluigi Tiesi wrote: > some time ago a change was added to vasnprintf, right now the line is: > 4958 in vasnprintf.c > > errno = 0 > > but it's never saved before, so I lose errno
Indeed, POSIX says in <http://www.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_03> "No function in this volume of POSIX.1-2008 shall set errno to zero." So, vasnprintf should also avoid to set errno to 0 without saving and restoring it. I'm applying this fix: 2010-10-14 Bruno Haible <br...@clisp.org> 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 <sher...@netfarm.it>. --- lib/vasnprintf.c.orig Fri Oct 15 02:00:19 2010 +++ lib/vasnprintf.c Fri Oct 15 01:57:02 2010 @@ -4599,6 +4599,7 @@ 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 @@ *(TCHAR_T *) (result + length) = '\0'; #endif + orig_errno = errno; + for (;;) { int count = -1; @@ -5499,6 +5502,7 @@ length += count; break; } + errno = orig_errno; #undef pad_ourselves #undef prec_ourselves }