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 <[email protected]>

* reformat

Signed-off-by: GoesM <[email protected]>

---------

Signed-off-by: GoesM <[email protected]>
Co-authored-by: GoesM <[email protected]>
  • Loading branch information
GoesM and GoesM committed Jan 29, 2024
1 parent b3a6a25 commit 8d191da
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 8d191da

Please sign in to comment.