orocos_kinematics_dynamics icon indicating copy to clipboard operation
orocos_kinematics_dynamics copied to clipboard

Prevent segfault in PyKDL when asking for nonexisting segment of chain

Open DriesDM opened this issue 5 years ago • 2 comments
trafficstars

Added methodcode to the Chain class to throw an IndexError when trying to retrieve a segment that doesn't exist.

DriesDM avatar Mar 13 '20 13:03 DriesDM

It should be noted that this change is not consistent with the C++ version of getSegment(), which deliberately does not implement any checks on the index, probably for performance reasons. In C++ it is up to the caller to make sure that the given index is valid.

https://github.com/orocos/orocos_kinematics_dynamics/blob/a2a2dff5eae7671c2d8db23d1173f6bb3cff6a29/orocos_kdl/src/chain.hpp#L78-L96

meyerj avatar Sep 07 '20 14:09 meyerj

@meyerj Do you think we should implement such checks for all index functions in PyKDL? I will work on a new PR as this one is outdated.

MatthijsBurgh avatar Sep 12 '21 07:09 MatthijsBurgh