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 7397610 commit e0759aa
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 @@ -335,6 +335,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 e0759aa

Please sign in to comment.