[pywin32-checkins] pywin32/com/win32com/src PyIUnknown.cpp,1.8,1.9
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <mha...@us...> - 2003-11-02 09:50:45
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1:/tmp/cvs-serv2751 Modified Files: PyIUnknown.cpp Log Message: If we failed create a return Python object for our COM object, we leaked a COM reference to the COM object. Index: PyIUnknown.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyIUnknown.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyIUnknown.cpp 31 Oct 2003 06:53:36 -0000 1.8 --- PyIUnknown.cpp 2 Nov 2003 09:50:42 -0000 1.9 *************** *** 233,237 **** if (pMyUnknown==NULL) return NULL; ! IUnknown *punk; PY_INTERFACE_PRECALL; HRESULT hr = pMyUnknown->QueryInterface(iid, (LPVOID*)&punk); --- 233,237 ---- if (pMyUnknown==NULL) return NULL; ! IUnknown *punk = NULL; PY_INTERFACE_PRECALL; HRESULT hr = pMyUnknown->QueryInterface(iid, (LPVOID*)&punk); *************** *** 239,247 **** /* Note that this failure may include E_NOINTERFACE */ ! if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pMyUnknown, IID_IUnknown); ! /* Return a type based on the IID (with no extra ref) */ ! PyObject *rc = PyCom_PyObjectFromIUnknown(punk, iid, FALSE); /* we may have been asked to use a different interface */ --- 239,250 ---- /* Note that this failure may include E_NOINTERFACE */ ! if ( FAILED(hr) || punk==NULL) return PyCom_BuildPyException(hr, pMyUnknown, IID_IUnknown); ! /* Return a type based on the IID. Note we can't ask PyCom_PyObjectFromIUnknown ! to own the reference, as we expect failure - and this will release our reference, ! which means we can't try again. So a new ref is added should they work. ! */ ! PyObject *rc = PyCom_PyObjectFromIUnknown(punk, iid, TRUE); /* we may have been asked to use a different interface */ *************** *** 249,253 **** { PyErr_Clear(); ! rc = PyCom_PyObjectFromIUnknown(punk, useIID, FALSE); } return rc; --- 252,261 ---- { PyErr_Clear(); ! rc = PyCom_PyObjectFromIUnknown(punk, useIID, TRUE); ! } ! { ! PY_INTERFACE_PRECALL; ! punk->Release(); ! PY_INTERFACE_POSTCALL; } return rc; |