Skip to content

Commit e0759aa

Browse files
GoesMGoesM
authored andcommitted
free map_sub_ before map_free(map_) to avoid UAF&&NullPtr bug mentioned 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>
1 parent 7397610 commit e0759aa

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

nav2_amcl/src/amcl_node.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ AmclNode::on_cleanup(const rclcpp_lifecycle::State & /*state*/)
335335
laser_scan_sub_.reset();
336336

337337
// Map
338+
map_sub_.reset(); // map_sub_ may access map_, so it should be reset earlier
338339
if (map_ != NULL) {
339340
map_free(map_);
340341
map_ = nullptr;

0 commit comments

Comments
 (0)