inline void ThrowErrno(const std::string& prefix) {
char buffer[MAXPATHLEN];
+ buffer[0] = 0;
#ifdef HAVE_STRERROR_R
// strerror_r is thread-safe.
- strerror_r(errno,buffer,MAXPATHLEN-1);
+ if (errno)
+ strerror_r(errno,buffer,MAXPATHLEN-1);
#elif HAVE_STRERROR
// Copy the thread un-safe result of strerror into
// the buffer as fast as possible to minimize impact
// of collision of strerror in multiple threads.
- strncpy(buffer,strerror(errno),MAXPATHLEN-1);
+ if (Errno)
+ strncpy(buffer,strerror(errno),MAXPATHLEN-1);
buffer[MAXPATHLEN-1] = 0;
#else
// Strange that this system doesn't even have strerror