[SCM] Samba Shared Repository - branch master updated
derrell.lipman at unwireduniverse.com
Fri Jan 15 18:07:21 MST 2010
On Fri, Jan 15, 2010 at 19:45, Jeremy Allison <jra at samba.org> wrote:
> On Thu, Jan 14, 2010 at 12:50:26PM -0600, Günther Deschner wrote:
> > +/* note the strdup for string options on smbc_set calls. I think
> libsmbclient is
> > + * really doing something wrong here: in smbc_free_context libsmbclient
> > + * calls free() on the string options so it assumes the callers have
> > + * them before setting them via smbc_set calls. */
> God you're right - that's *REALLY* horrible. libsmbclient
> should have been deep copying the strings from the start,
> not just stealing the pointers.
I missed the beginning of this conversation. The message including Gunther's
above comment didn't arrive here.
I'm looking at smbc_free_context for free() calls to see what this is
referring to. I see that I free the return value of smbc_getWorkgroup(),
etc, thus the smbc_set calls it refers to would be the like of
smbc_setWorkgroup(). I'm pretty sure that these were previously simple
assignments before I added the set/get interface, so it's "always" been this
way, with the assumption that those values are malloc'ed. That not
withstanding, certainly, if that was the assumption, it would have been nice
if it had been documented it in libsmbclient.h.
Converting this to a deep copy is perfectly reasonable, with the caveat that
code expecting their pointer to be freed will end up with a memory leak if
not otherwise changed.
More information about the samba-technical