diff --git a/src/mdbx.c b/src/mdbx.c index c6c8a41b..480b9a38 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -1134,7 +1134,7 @@ const char *__cold mdbx_strerror(int errnum) { const char *msg = __mdbx_strerr(errnum); if (!msg) { #ifdef _MSC_VER - static __thread char buffer[1024]; + static char buffer[1024]; size_t size = FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errnum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, @@ -1142,6 +1142,13 @@ const char *__cold mdbx_strerror(int errnum) { if (size) msg = buffer; #else + if (errnum < 0) { + static char buffer[32]; + int rc = snprintf(buffer, sizeof(buffer) - 1, "unknown error %d", errnum); + assert(rc > 0); + (void)rc; + return buffer; + } msg = strerror(errnum); #endif }