mz-automation / libiec61850

Official repository for libIEC61850, the open-source library for the IEC 61850 protocols
http://libiec61850.com/libiec61850
GNU General Public License v3.0
828 stars 444 forks source link

Memory leak in 'SVReceiver_start' function #471

Open hovhannes-96 opened 10 months ago

hovhannes-96 commented 10 months ago

The memory leak is reported by a static analyzer developed at CAST (https://www.linkedin.com/company/cast-center).

In src/sampled_values/sv_subscriber.c:196 call of Thread_create allocates and returns dynamic memory which is not freed.

mbourhis commented 9 months ago

Hi, this instance of Thread (src/sampled_values/sv_subscriber.c:196) is an 'autodestroy' Thread.

The allocated 'autodestroy' Thread objects are freed in the 'destroyAutomaticThread()' function (hal/thread/linux/thread_linux.c:76 or hal/thread/win32/thread_win32.c:78) once the thread subroutine is ended (here svReceiverLoop()), because the API function 'SVReceiver_stop()' has been called.