From d9983a5443ed70139c695c3a6e173e5e6ce1798b Mon Sep 17 00:00:00 2001 From: Yong-Hao Zou Date: Thu, 2 Sep 2021 06:01:25 +0800 Subject: [PATCH] Use worldToMapEnforceBounds in clear_costmap_service (#2544) to avoid buffer overflow Signed-off-by: zouyonghao --- nav2_costmap_2d/src/clear_costmap_service.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nav2_costmap_2d/src/clear_costmap_service.cpp b/nav2_costmap_2d/src/clear_costmap_service.cpp index 922478bb0dd..18039f4298f 100644 --- a/nav2_costmap_2d/src/clear_costmap_service.cpp +++ b/nav2_costmap_2d/src/clear_costmap_service.cpp @@ -129,8 +129,8 @@ void ClearCostmapService::clearLayerRegion( double end_point_y = start_point_y + reset_distance; int start_x, start_y, end_x, end_y; - costmap->worldToMapNoBounds(start_point_x, start_point_y, start_x, start_y); - costmap->worldToMapNoBounds(end_point_x, end_point_y, end_x, end_y); + costmap->worldToMapEnforceBounds(start_point_x, start_point_y, start_x, start_y); + costmap->worldToMapEnforceBounds(end_point_x, end_point_y, end_x, end_y); costmap->clearArea(start_x, start_y, end_x, end_y, invert);