Yes, I've done the same except that I've used Py_DECREF since the references are guarded by previous non null tests.


2006/7/9, Harold J. Ship <>:
Just to be sure, this is the change I've made to util.c (marked with @HJS):
    while (dir) {
        PyObject *t = Py_BuildValue("(s, s)", dir->directive, dir->args);
        if (!t)
            return PyErr_NoMemory();
        PyList_Append(list, t);
        Py_XDECREF(t); // @HJS
        if (dir->first_child) {
            PyObject *child = cfgtree_walk(dir->first_child);
            if (!child)
                return PyErr_NoMemory();
            PyList_Append(list, child);
            Py_XDECREF(child); // @HJS
        dir = dir->next;

From: [] On Behalf Of Nicolas Lehuen
Sent: Sunday, July 09, 2006 11:46 AM
To: Harold J. Ship
Subject: Re: Commented: (MODPYTHON-172) Memory leak with util.fieldstorage using mod_python 3.2.8 on apache 2.0.55

OK, I'm currently checking in the fixes you suggested on the trunk. Too bad we cannot write a unit test that checks for memory leaks.

Jim, Graham, what shall we do for the 3.2.9 release ? Shall we keep on with the current branch or backport the fixes ?


2006/7/9, Harold Ship <>:

I've made a test build based on 3.2.8 release, where I've added Py_XDECREF()
calls in parse_qsl(), cfgtree_walk() TWICE (one on t, one on child), and

My foo/bar program doesn't leak, and I'm now testing my full application. So
far, it seems to be ok.