From f6dd8af4f6d9c329bcfd47c6aeb3d0a8fe323990 Mon Sep 17 00:00:00 2001 From: Yong-Hao Zou Date: Thu, 12 Aug 2021 12:06:33 +0800 Subject: [PATCH] Fix null pointer in amcl on_cleanup --- nav2_amcl/src/amcl_node.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nav2_amcl/src/amcl_node.cpp b/nav2_amcl/src/amcl_node.cpp index 0e4fc20911..f1c0a6e556 100644 --- a/nav2_amcl/src/amcl_node.cpp +++ b/nav2_amcl/src/amcl_node.cpp @@ -335,8 +335,10 @@ AmclNode::on_cleanup(const rclcpp_lifecycle::State & /*state*/) laser_scan_sub_.reset(); // Map - map_free(map_); - map_ = nullptr; + if (map_ != NULL) { + map_free(map_); + map_ = nullptr; + } first_map_received_ = false; free_space_indices.resize(0);