mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
The AI deadlock message hands ScreenMsg an object where its format string
promises a pointer:
ScreenMsg(..., L"Aborting AI deadlock for [%d] %s %s data %d",
pSoldier->ubID.i, pSoldier->GetName(),
utf8_to_wstring(std::string(szAction[...])), ...);
utf8_to_wstring returns std::wstring by value. ScreenMsg is variadic, so the
whole object is pushed and %s then reads the first bytes of it as a pointer.
What that prints, or whether it survives printing it, is not defined. clang
says as much: the call will abort at runtime.
Adding .c_str() passes what the format asked for. The temporary lives until
the end of the statement, so the pointer is good for the duration of the call.
The only other use of utf8_to_wstring in this file has the same shape and is
commented out; it is left as it is.
Verification:
ninja -C build parse # AIMain.cpp clean
ninja -C build -k 0 # Release, four applications, green
ninja -C build-debug -k 0 # Debug, four applications, green
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>