[PyKDE] SIP Leak during exception
James Emerton
ephelon at gmail.com
Wed Jan 4 01:32:45 GMT 2006
Method calling code produced by SIP fails to delete temporary varibles
created by user defined conversion routines.
I've attached some generated code that demonstrates this. Note the a0
and a1 are not cleaned up before NULL is returned from the exception.
Attached is a patch which corrects the problem, if a little
gracelessly. The patch was created against SIP v4.3.2.
James
static PyObject *meth_BVE_IInventoryManager_LoadInventory(PyObject
*sipSelf,PyObject *sipArgs)
{
int sipArgsParsed = 0;
{
const std::string * a0;
int a0IsTemp = 0;
const std::string * a1;
int a1IsTemp = 0;
BVE_IInventoryManager *sipCpp;
if (sipParseArgs(&sipArgsParsed,sipArgs,"mM1M1",sipSelf,sipClass_BVE_IInventoryManager,&sipCpp,sipConvertTo_std_string,&a0,&a0IsTemp,sipConvertTo_std_string,&a1,&a1IsTemp))
{
BVE_IInventoryPtr *sipRes;
try
{
sipRes = new BVE_IInventoryPtr(sipCpp -> LoadBVEInventory(*a0,*a1));
}
catch (record_not_found &e)
{
/* Hope that there is a valid copy ctor. */
record_not_found *sipCpp = new record_not_found(e);
sipRaiseClassException(sipClass_record_not_found,sipCpp);
return NULL;
}
if (a0IsTemp)
delete const_cast<std::string *>(a0);
if (a1IsTemp)
delete const_cast<std::string *>(a1);
PyObject *sipResObj = sipConvertFrom_BVE_IInventoryPtr(sipRes);
delete sipRes;
return sipResObj;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipArgsParsed,sipNm_bve_BVE_IInventoryManager,sipNm_bve_LoadInventory);
return NULL;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gencode.c.diff
Type: application/octet-stream
Size: 1761 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20060104/09d0da8b/gencode.c.obj
More information about the PyQt
mailing list