X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;ds=sidebyside;f=src%2Futils.c;h=94052d3d02d6986329b3295734b975c7a33bff25;hb=15b02e0766ce4fdbf604489fdb1f55c9a0cce850;hp=92505b4a6f8a17a60f8f60a9dbb88c18214075a8;hpb=e99687f6b8c784e9a1805d1435e91a08b4ea6408;p=meshlink diff --git a/src/utils.c b/src/utils.c index 92505b4a..94052d3d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -178,19 +178,16 @@ int b64encode_urlsafe(const void *src, char *dst, int length) { #endif const char *winerror(int err) { - static char buf[1024], *ptr; + char buf[1024], *ptr; ptr = buf + sprintf(buf, "(%d) ", err); - if(!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), ptr, sizeof(buf) - (ptr - buf), NULL)) { + if(!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), ptr, sizeof(buf) - (ptr - buf), NULL)) { strncpy(buf, "(unable to format errormessage)", sizeof(buf)); } - ; - if((ptr = strchr(buf, '\r'))) { - * ptr = '\0'; + *ptr = '\0'; } return buf;