yarp
yarp copied to clipboard
Possible access to dangling pointer in yarpbroker.cpp
Describe the bug While reading the code to understand the issue behind https://github.com/robotology/yarp/issues/3104, I came across a warning by the Visual Studio static analyzer.
In particular, the following lines https://github.com/robotology/yarp/blob/e4762b0b4a7946bf9379b183379bd32353d54a26/src/libYARP_manager/src/yarp/manager/yarpbroker.cpp#L566-L576
return a pointer to the char buffer of a temporary string.
Configuration (please complete the following information):
- OS:
- yarp version: 3.9.0
- compiler:
Additional context Add any other context about the problem here.
cc @randaz81
Probably fixed. Can you give it a check @S-Dafarra ?
I believe it should be fixed, thanks a lot! I noticed that there is the c_str() in https://github.com/randaz81/yarp/blob/a62e65eb9ab1906a8e29e947e04629df20293d2c/src/libYARP_manager/src/yarp/manager/yarpbroker.cpp#L575, but since the method outputs a string by copy, it should not be an issue anymore.