-
Notifications
You must be signed in to change notification settings - Fork 21.2k
Description
Hi, I have found a potential memory leak bug in src/darknet.c and would like to report it to the maintainers. Can you please help me to check it? Thank you for your effort and patience!
step 1:
In the function xcalloc_location in file src/utils, the pointer ptr is allocated memory and returned to the caller.
step2:
In the function recalculate_workspace_size in file src/network.c, xcalloc_location is called (in macro xcalloc) and net->workspace receives the allocated memory, where net is a param of recalculate_workspace_size.
step3:
In the function set_batch_network in file src/network.c, recalculate_workspace_size is called and net is also a param of set_batch_network.
step4:
In the function speed in file src/darknet.c, set_batch_network is called and net is local. net->workspace is not freed in speed, which may lead to memory leak.
Also, the same risk exists in the function load_thread in file src/data.c. The image below presents the execution trace.

