xArm-Developer / xArm-CPLUS-SDK

C++ SDK for UFACTORY robots, 850, xArm5/6/7, and Lite6.
https://www.ufactory.cc/
BSD 3-Clause "New" or "Revised" License
44 stars 29 forks source link

compare_version() uses new without delete #11

Closed BryanStuurman closed 2 years ago

BryanStuurman commented 2 years ago

Inside set_tcp_load() makes a call to compare_version() with a new: if (compare_version(version_number, new int[3]{ 0, 2, 0 })) { https://github.com/xArm-Developer/xArm-CPLUS-SDK/blob/master/src/xarm/wrapper/xarm_params.cc#L59

In my understanding, the pointer returned by new is lost when the function returns, however the memory remains allocated until delete can be called on that pointer (new is not affected by scope) - this would be a memory leak.

vimior commented 2 years ago

@BryanStuurman thanks for reminding.

BryanStuurman commented 2 years ago

Looks good, thanks! a closing note: code that subrepos this SDK should probably be updated to point to this most recent commit as well.