Mark Hammond wrote:
>
> John Bandhauer wrote:
>
> > A quick look at one use in PyXPCOM shows it also freeing the
> > alloc'd iid a couple steps later.
>
> Actually, this one looks bad to me. I believe the following patch makes it right:
>
> Index: PyIInterfaceInfo.cpp
> ===================================================================
> RCS file: /cvsroot/mozilla/extensions/python/xpcom/src/PyIInterfaceInfo.cpp,v
> retrieving revision 1.2
> diff -u -r1.2 PyIInterfaceInfo.cpp
> --- PyIInterfaceInfo.cpp 2001/02/19 08:31:31 1.2
> +++ PyIInterfaceInfo.cpp 2001/03/24 05:12:30
> @@ -293,7 +293,9 @@
> nsresult n = pii->GetIIDForParam(mi, ¶m_info, &piid);
> if (NS_FAILED(n) || piid==nsnull)
> return PyXPCOM_BuildPyException(n);
> - return Py_nsIID::PyObjectFromIID(*piid);
> + PyObject *rc = Py_nsIID::PyObjectFromIID(*piid);
> + nsMemory::Free((void*)piid);
> + return rc;
> }
>
> static PyObject *PyGetTypeForParam(PyObject *self, PyObject *args)
>
> Mark.
Ah. Yes. My 'quick look' was a different call to PyObjectFromIID
where you were explicitly freeing the iid.
John.