From 760655694d97512c22793c93c14c5406945445aa Mon Sep 17 00:00:00 2001 From: GoesM <130988564+GoesM@users.noreply.github.com> Date: Sat, 20 Jul 2024 00:44:46 +0800 Subject: [PATCH] check nullptr in smoothPlan() (#4544) * check nullptr in smoothPlan() Signed-off-by: GoesM * code-style Signed-off-by: GoesM * code-style Signed-off-by: GoesM * simple change Signed-off-by: GoesM --------- Signed-off-by: GoesM Co-authored-by: GoesM --- nav2_smoother/src/nav2_smoother.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nav2_smoother/src/nav2_smoother.cpp b/nav2_smoother/src/nav2_smoother.cpp index 4e7f7242de..e7baa5e483 100644 --- a/nav2_smoother/src/nav2_smoother.cpp +++ b/nav2_smoother/src/nav2_smoother.cpp @@ -265,7 +265,12 @@ void SmootherServer::smoothPlan() auto result = std::make_shared(); try { - std::string c_name = action_server_->get_current_goal()->smoother_id; + auto goal = action_server_->get_current_goal(); + if (!goal) { + return; // if action_server_ is inactivate, goal would be a nullptr + } + + std::string c_name = goal->smoother_id; std::string current_smoother; if (findSmootherId(c_name, current_smoother)) { current_smoother_ = current_smoother; @@ -274,7 +279,6 @@ void SmootherServer::smoothPlan() } // Perform smoothing - auto goal = action_server_->get_current_goal(); result->path = goal->path; if (!validate(result->path)) {