From 323ec9809e4eb7ddeae9e10ba8c06a3c94d3cd5d Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Thu, 30 May 2024 15:37:47 +0900 Subject: [PATCH] fix(autonomous_emergency_braking): fix invalid access to imu_ptr Signed-off-by: Mamoru Sobue --- control/autonomous_emergency_braking/src/node.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/control/autonomous_emergency_braking/src/node.cpp b/control/autonomous_emergency_braking/src/node.cpp index 905b66df288b4..71eb92a4e95fb 100644 --- a/control/autonomous_emergency_braking/src/node.cpp +++ b/control/autonomous_emergency_braking/src/node.cpp @@ -301,10 +301,13 @@ bool AEB::fetchLatestData() } const auto imu_ptr = sub_imu_.takeData(); - if (use_imu_path_ && !imu_ptr) { - return missing("imu message"); + if (use_imu_path_) { + if (!imu_ptr) { + return missing("imu message"); + } + // imu_ptr is valid + onImu(imu_ptr); } - onImu(imu_ptr); if (use_imu_path_ && !angular_velocity_ptr_) { return missing("imu"); }