ConsoleListener: fix crash if useThread_ is ever set false

hTriggerEvent/criticalSection/logPending_ were only initialized when
useThread_ was true, but Log() falls back to SendToThread() (which
uses all three) whenever the console isn't open yet, regardless of
useThread_. With useThread_ false, that meant an uninitialized
CRITICAL_SECTION and a null logPending_ write. Dead path today (only
reachable via a commented-out line), but now initializes unconditionally.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L4QAoxV2KY7ek4PcZw3WvY
This commit is contained in:
Henrik RydgårdandClaude Sonnet 5 committed 2026-08-09 19:03:28 +02:00
1 parent 1c0e5ae48c
commit 78b25599f3
1 file changed
+3 -1
+3 -1
View File
@@ -49,7 +49,9 @@ ConsoleListener::ConsoleListener() : hidden_(true) {
// useThread_ = false;
if (useThread_ && !hTriggerEvent) {
// Always initialized, since SendToThread() (used by Log() whenever the console
// isn't open yet, regardless of useThread_) needs these to be valid.
if (!hTriggerEvent) {
hTriggerEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
InitializeCriticalSection(&criticalSection);
logPending_ = new char[LOG_PENDING_MAX];