Skip to content

Commit ec9bb2b

Browse files
GoesMGoesM
authored andcommitted
check nullptr in smoothPlan() (#4544)
* check nullptr in smoothPlan() Signed-off-by: GoesM <[email protected]> * code-style Signed-off-by: GoesM <[email protected]> * code-style Signed-off-by: GoesM <[email protected]> * simple change Signed-off-by: GoesM <[email protected]> --------- Signed-off-by: GoesM <[email protected]> Co-authored-by: GoesM <[email protected]>
1 parent 23ad6fe commit ec9bb2b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

nav2_smoother/src/nav2_smoother.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,12 @@ void SmootherServer::smoothPlan()
265265

266266
auto result = std::make_shared<Action::Result>();
267267
try {
268-
std::string c_name = action_server_->get_current_goal()->smoother_id;
268+
auto goal = action_server_->get_current_goal();
269+
if (!goal) {
270+
return; // if action_server_ is inactivate, goal would be a nullptr
271+
}
272+
273+
std::string c_name = goal->smoother_id;
269274
std::string current_smoother;
270275
if (findSmootherId(c_name, current_smoother)) {
271276
current_smoother_ = current_smoother;
@@ -274,7 +279,6 @@ void SmootherServer::smoothPlan()
274279
}
275280

276281
// Perform smoothing
277-
auto goal = action_server_->get_current_goal();
278282
result->path = goal->path;
279283

280284
if (!validate(result->path)) {

0 commit comments

Comments
 (0)