diff --git a/src/common/psprintf.c b/src/common/psprintf.c index 41c39c4..ee2e820 100644 --- a/src/common/psprintf.c +++ b/src/common/psprintf.c @@ -97,9 +97,11 @@ size_t pvsnprintf(char *buf, size_t len, const char *fmt, va_list args) { int nprinted; + int saved_errno; Assert(len > 0); + saved_errno = errno; errno = 0; /* @@ -129,6 +131,8 @@ pvsnprintf(char *buf, size_t len, const char *fmt, va_list args) #endif } + errno = saved_errno; + /* * Note: some versions of vsnprintf return the number of chars actually * stored, not the total space needed as C99 specifies. And at least one