From 2b6811eddb9f8bf3593013a242213f1963e96f1f Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 1 Nov 2019 23:42:01 -0700 Subject: [PATCH] Fix null pointer dereference in C++ CommandScheduler (#2023) Java has a null check that was missing in C++ when adding default commands. --- .../src/main/native/cpp/frc2/command/CommandScheduler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp index 66885e17f8..7a12a86eb7 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp @@ -174,7 +174,7 @@ void CommandScheduler::Run() { // Add default commands for un-required registered subsystems. for (auto&& subsystem : m_subsystems) { auto s = m_requirements.find(subsystem.getFirst()); - if (s == m_requirements.end()) { + if (s == m_requirements.end() && subsystem.getSecond()) { Schedule({subsystem.getSecond().get()}); } }