ros-drivers / urg_node

ROS wrapper for the Hokuyo urg_c library.
Other
99 stars 148 forks source link

Empty return value from sendCommand causes a crash #104

Closed richardw347 closed 1 year ago

richardw347 commented 1 year ago

A quick bug fix, I found that an error in the sendCommand function in urg_c_wrapper returns an empty string. However none of the callers are checking for an empty string so this results in an unhandled std::out_of_range exception:

[urg_node_driver-25] [ERROR 1679511084.962595117] [urg_node_front_left_node]: Buffer creation bounds exceeded, shouldn't allocate: 4294967291 bytes (sendCommand() at /root/v2.0.6/src/urg_node/src/urg_c_wrapper.cpp:597)
[urg_node_driver-25] terminate called after throwing an instance of 'std::out_of_range'
[urg_node_driver-25]   what():  basic_string::erase: __pos (which is 18446744073709551615) > this->size() (which is 0)
[ERROR] [urg_node_driver-25]: process has died [pid 42882, exit code -6, cmd '/

This PR just adds an empty string check in the two callers to prevent the crash. There are probably not many people using the detailed status but we're using it on the UAM-05LP-T301 to get the error codes so very useful to get this fixed.