[JDEV] Leak, bug -- fixed -- maybe

Jeremie jeremie at jabber.org
Tue Apr 2 00:44:06 CST 2002


Hey Glenn, few questions to clarify here, and following up to the
jabberd at jabberstudio.org list as well.

> jsm/session.c at _js_session_from you will see at line 252 or so that we
> create a new jid struct using jid_full with the session->id meaning that the
> new jid is allocated from the session pool, not good. 

Are you talking about this code? (and the line marked with ->)

    /* if you use to="yourself at yourhost" it's the same as not having a ... */
->  uid = jid_user(s->id);
    if(jid_cmp(p->to,uid) == 0)
    {
        /* xmlnode_hide_attrib(p->x,"to"); */
        p->to = NULL;
    }

Just curious, because yes, that is a leak with using the jid_user()
function on the session id... but from your wording:

> So we have created a new jid_full function, jid_full_from_pool(pool, jid).

... it sounds like you are saying a call to jid_full(s->id) would leak,
and it doesn't because the implementation in jid.c 'caches' the results:

    /* use cached copy */
    if(id->full != NULL)
        return id->full;

So it is safe to use jid_full() many numbers of times on a "static" jid
like the one in the session.

> changed much so if the plan was to reuse some of the jsm and jabberd stuff
> in the 1.5 it maybe good to get it in.

Yes, much of the jsm code is going to be reused, at least initially to get
1.5 rolling. Since you pointed this out I looked at other suspect uses of
jid_user, and there are numerous other problems in the modules (my bad)
that I'll look at and make sure are fixed for 1.5.

If you want to work up a patch without having to figure out where it's
used incorrectly in jsm, the easiest fix for jid_user might be to make it
work like jid_full, cache the returned user-only jid in the struct so that
it is only ever generated once.  Just post it to the jdev and jabberd
lists, if you plan on having any more patches then cvs access is available
as well (just ask).

Thanks for finding this, so far 1.5 is getting a pretty serious overhaul
and it'll be easier for us all to track down and fix some of these
problems :)

Jer





More information about the JDev mailing list