libstorage / libstoragemgmt

A library for storage management
https://libstorage.github.io/libstoragemgmt-doc/
GNU Lesser General Public License v2.1
82 stars 32 forks source link

Fix Memleak warning #504

Closed tasleson closed 2 years ago

tasleson commented 2 years ago

When compiling with -fanalyzer compiler option, the compiler was warning that the memory pointed to by dp was leaked. The following change is a simplification and adds more defensive programming by ensuring dp is not dangling after the memory that it pointed to is assigned to the array. The warning in this case was incorrect, but the changes do simplify and improve.