From 2ae646136e3ea2d1bc7e50b2503fb3ad96623031 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 29 Jun 2023 23:45:22 -0400 Subject: [PATCH] Prevent crashes on invalid use of tools See https://gitlab.com/kicad/code/kicad/-/issues/15085 --- common/tool/tool_manager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 9155aa9790..2493b47084 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -663,6 +663,7 @@ void TOOL_MANAGER::RunMainStack( TOOL_BASE* aTool, std::function aFunc ) { TOOL_STATE* st = m_toolState[aTool]; setActiveState( st ); + wxCHECK( st->cofunc, /* void */ ); st->cofunc->RunMainStack( std::move( aFunc ) ); } @@ -678,6 +679,8 @@ TOOL_EVENT* TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool, const TOOL_EVENT_LIST& st->pendingWait = true; st->waitEvents = aConditions; + wxCHECK( st->cofunc, nullptr ); + // switch context back to event dispatcher loop st->cofunc->KiYield();