yarp icon indicating copy to clipboard operation
yarp copied to clipboard

Possible access to dangling pointer in yarpbroker.cpp

Open S-Dafarra opened this issue 1 year ago • 2 comments
trafficstars

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

S-Dafarra avatar Apr 17 '24 07:04 S-Dafarra

Probably fixed. Can you give it a check @S-Dafarra ?

randaz81 avatar Aug 30 '24 08:08 randaz81

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.

S-Dafarra avatar Aug 30 '24 08:08 S-Dafarra