The fix to the problem described in https://connect.microsoft.com/VisualStudio/feedback/details/555863/cstring-formatmessage-throws-out-of-memory-if-result-string-is-emptyhas caused another problem.The new code simply checks GetLastError() return value without checking for return value of FormatMessage. As a result this function can (and has for us) throw out of memory exception when there is actually no problem and a formatted string is successfully returned in the supplied buffer.I am guessing some internal Windows API sets an error during FormatMessage execution.The correct way of fixing this would be to check for return value of FormatMessage and if it is 0 then check GetLastError() return value and only then throw an error.
Visual Studio/Team Foundation Server/.NET Framework Tooling version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results