memory leaks in vfs_catia and vfs_cap modules ?

Jeremy Allison jra at samba.org
Thu Feb 12 11:30:34 MST 2009


On Tue, Feb 10, 2009 at 09:35:26PM +0100, Olivier Sessink wrote:
> Hi all,
> 
> while looking around in other code how to add a feature to the
> scannedonly samba vfs module I either found some memory leaks in
> vfs_catia and vfs_cap or I don't understand how samba manages the VFS
> module memory.
> 
> Both vfs_catia and vfs_cap change the name of the files in their
> _readdir() implementations. Both VFS modules allocate a new
> SMB_STRUCT_DIRENT and return that to the caller. But both modules
> don't keep track of the allocated pointer, so how is this memory ever
> freed? The caller of the _readdir() function is not supposed to free
> the result, right?
> 
> Can anyone shed some light on this issue? Is my understanding of the
> VFS module memory management wrong, or are there indeed memory leaks
> in these modules?

Just looking at the vfs_catia module it uses TALLOC_ARRAY(talloc_tos(),
to allocate the new SMB_STRUCT_DIRENT. The talloc library keeps track
of the allocated pointer, and as soon as the talloc frame returned by
talloc_tos() is freed, (usually the calling function), then the memory
is freed.

Jeremy.


More information about the samba-technical mailing list