ninja-build / ninja

a small build system with a focus on speed

Home Page:https://ninja-build.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash in GetLastErrorString(): FormatMessageA may set out-param lpBuffer to NULL

jheydebrand opened this issue · comments

The call to

FormatMessageA(
may set the local variable msg_buf to nullptr. This leads to an access violation and subsequent crash when that char pointer is assigned to the std::string (because it's constructor will try to perform strlen on that nullptr).

This happend to me on one of my machines. However, I did not bother to try to find out which Windows component is (presumably) missing that would restore the expected FormatMessageA behaviour.

If FormatMessageA was unable to provide a usable message, ninja should probably just format the DWORD err into a string.
I will create a pull request with this proposed fix.

grafik