Created attachment 18241 [details] misc.c:80-85 The static analyzer has detected MEMORY_LEAK: dynamic memory, referenced by 'fname', is allocated at misc.c:80 by calling function 'asprintf' and lost at misc.c:84. Seems that it is necessary to add free(fname) at misc.c:80-85 just as it is done at misc.c:134. Because without free(fname) at misc.c:84 an early exit from the function may cause a leak of the memory. GitHub: 1) misc.c:80-85 https://github.com/samba-team/samba/blob/225a003a043eee399b6d266d94440c399b6877e4/source4/torture/basic/misc.c#L80C1-L86C1 2) misc.c:134 https://github.com/samba-team/samba/blob/225a003a043eee399b6d266d94440c399b6877e4/source4/torture/basic/misc.c#L134C1-L135C3 Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE. Author E. Bykhanova (e.bykhanova@fobos-nt.ru).
There are more places in this routine where we leak fname. For example the "break;" statement in line 91 also leads to a leak of that memory. In general, smbtorture is not any code that is supposed to be long-running in production, this is really a one-off command. I don't see that we obviously leak in the for-loop and for me that would be enough. If you really need to fix it for your compliance tests, I would recommend converting that routine to using talloc, see https://talloc.samba.org/talloc/doc/html/index.html. Happy to accept patches.