[Support] Fix StrError on Windows to actually return the error string...
authorMichael J. Spencer <bigcheesegs@gmail.com>
Thu, 1 Nov 2012 00:34:09 +0000 (00:34 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Thu, 1 Nov 2012 00:34:09 +0000 (00:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167191 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Errno.cpp

index 00be43b75037cdb67c996ae0fefaac0ee8938bbf..730220f47d924b354cc967a7354e51a8be357bef 100644 (file)
@@ -53,8 +53,10 @@ std::string StrError(int errnum) {
     str = buffer;
 # endif
 #elif HAVE_DECL_STRERROR_S // "Windows Secure API"
     str = buffer;
 # endif
 #elif HAVE_DECL_STRERROR_S // "Windows Secure API"
-    if (errnum)
+    if (errnum) {
       strerror_s(buffer, MaxErrStrLen - 1, errnum);
       strerror_s(buffer, MaxErrStrLen - 1, errnum);
+      str = buffer;
+    }
 #elif defined(HAVE_STRERROR)
   // Copy the thread un-safe result of strerror into
   // the buffer as fast as possible to minimize impact
 #elif defined(HAVE_STRERROR)
   // Copy the thread un-safe result of strerror into
   // the buffer as fast as possible to minimize impact