Skip to content

Commit

Permalink
fix memory dereferencing bug in DiffDriveController::reset_buffers()
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibault Poignonec committed Feb 6, 2025
1 parent 5486fcd commit adc7fb2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion diff_drive_controller/src/diff_drive_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,9 @@ bool DiffDriveController::reset()

void DiffDriveController::reset_buffers()
{
reference_interfaces_ = std::vector<double>(2, std::numeric_limits<double>::quiet_NaN());
std::fill(
reference_interfaces_.begin(), reference_interfaces_.end(),
std::numeric_limits<double>::quiet_NaN());
// Empty out the old queue. Fill with zeros (not NaN) to catch early accelerations.
std::queue<std::array<double, 2>> empty;
std::swap(previous_two_commands_, empty);
Expand Down

0 comments on commit adc7fb2

Please sign in to comment.