Skip to content

Commit

Permalink
free map_sub_ before map_free(map_) to avoid UAF&&NullPtr bug men…
Browse files Browse the repository at this point in the history
…tioned in ros-navigation#4078 (ros-navigation#4079)

* free `map_sub_` before `map_free(map_)`

Signed-off-by: GoesM <GoesM@buaa.edu.cn>

* reformat

Signed-off-by: GoesM <GoesM@buaa.edu.cn>

---------

Signed-off-by: GoesM <GoesM@buaa.edu.cn>
Co-authored-by: GoesM <GoesM@buaa.edu.cn>
Signed-off-by: enricosutera <enricosutera@outlook.com>
  • Loading branch information
2 people authored and enricosutera committed May 19, 2024
1 parent 0805191 commit 3728794
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions nav2_amcl/src/amcl_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ AmclNode::on_cleanup(const rclcpp_lifecycle::State & /*state*/)
laser_scan_sub_.reset();

// Map
map_sub_.reset(); // map_sub_ may access map_, so it should be reset earlier
if (map_ != NULL) {
map_free(map_);
map_ = nullptr;
Expand Down

0 comments on commit 3728794

Please sign in to comment.