[PATCH] Add stackframes to public libsmbclient functions
derrell.lipman at unwireduniverse.com
Mon Nov 19 14:25:35 GMT 2007
On Nov 19, 2007 6:36 AM, Volker Lendecke <vl at sernet.de> wrote:
> As we use talloc_tos() in inner libsmbclient/ functions more and more, we need
> to make sure not to create memleaks by not free'ing talloc stackframes. This
> patch wraps all calls in libsmbclient.c that are publically exported into a
> talloc_stackframe()/talloc_free() pair.
> Jeremy, Derrell, can you check this?
I went back and reviewed your original check-in message for the
talloc_stackframe() functionality. I see and agree with the conceptt,
but I don't at all like these changes to libsmbclient. This has
imposed a new requirement that libsmbclient remember to allocate a
stack frame and free it in every single function, even though in
nearly every case, that stack frame is unused in libsmbclient itself.
It looks to me like what's happening here is that the bugs at lower
layers (forgetting to free allocated memory) are being pushed into
libsmbclient and silently handled rather than alerting the developer
of the lower-level function that there's a problem down below. That's
not the way to do it IMO.
I'd have no problem with adding a call to talloc_stackframe() only in
smbc_init_context() (which is called once, typically) and providing an
atexit() handler to display a list of any still-allocated memory.
This would allow catching the bugs rather than kludgedly "fixing"
The patch you provided is, I think, overly burdensome on libsmbclient
for not enough gain. Let's get rid of the memory leaks where they
occur rather than trying to kludge it at higher layers.
More information about the samba-technical