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 #4078 (#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>
  • Loading branch information
2 people authored and SteveMacenski committed Apr 4, 2024
1 parent 3c61381 commit 03922d2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions nav2_amcl/src/amcl_node.cpp
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 03922d2

Please sign in to comment.