From 36b0b2bde9f49c2d1700266fcb50afff12d618b9 Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Tue, 11 Jun 2024 23:50:21 +0900 Subject: [PATCH] fix(operation mode manager): add nullptr check in onTimer (#7446) Signed-off-by: Mamoru Sobue --- .../src/node.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/control/autoware_operation_mode_transition_manager/src/node.cpp b/control/autoware_operation_mode_transition_manager/src/node.cpp index ed9351aa0b079..a93c0b93741a1 100644 --- a/control/autoware_operation_mode_transition_manager/src/node.cpp +++ b/control/autoware_operation_mode_transition_manager/src/node.cpp @@ -206,8 +206,16 @@ void OperationModeTransitionManager::processTransition() void OperationModeTransitionManager::onTimer() { - control_mode_report_ = *sub_control_mode_report_.takeData(); - gate_operation_mode_ = *sub_gate_operation_mode_.takeData(); + const auto control_mode_report_ptr = sub_control_mode_report_.takeData(); + if (!control_mode_report_ptr) { + return; + } + const auto gate_operation_mode_ptr = sub_gate_operation_mode_.takeData(); + if (!gate_operation_mode_ptr) { + return; + } + control_mode_report_ = *control_mode_report_ptr; + gate_operation_mode_ = *gate_operation_mode_ptr; for (const auto & [type, mode] : modes_) { mode->update(current_mode_ == type && transition_);