Update of /cvsroot/pywin32/pywin32/com/win32com/src
In directory sc8-pr-cvs1:/tmp/cvs-serv2481
Modified Files:
PyComHelpers.cpp
Log Message:
If PyCom_PyObjectFromIUnknown() failed and we have been asked to own the
COM reference, release the reference.
Index: PyComHelpers.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyComHelpers.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PyComHelpers.cpp 31 Oct 2003 09:36:52 -0000 1.5
--- PyComHelpers.cpp 2 Nov 2003 09:48:13 -0000 1.6
***************
*** 66,69 ****
--- 66,80 ----
}
+ // If PyCom_PyObjectFromIUnknown is called with bAddRef==FALSE, the
+ // caller is asking us to take ownership of the COM reference. If we
+ // fail to create a Python object, we must release the reference.
+ #define POFIU_RELEASE_ON_FAILURE \
+ if (!bAddRef) { \
+ PY_INTERFACE_PRECALL; \
+ punk->Release(); \
+ PY_INTERFACE_POSTCALL; \
+ }
+
+
// Interface conversions
PyObject *PyCom_PyObjectFromIUnknown(IUnknown *punk, REFIID riid, BOOL bAddRef /* = FALSE */)
***************
*** 84,87 ****
--- 95,99 ----
PyErr_Clear();
PyErr_SetString(PyExc_TypeError, "There is no interface object registered that supports this IID");
+ POFIU_RELEASE_ON_FAILURE
return NULL;
}
***************
*** 90,93 ****
--- 102,106 ----
if ( !PyComTypeObject::is_interface_type(createType) ) {
PyErr_SetString(PyExc_TypeError, "The Python IID map is invalid - the value is not an interface type object");
+ POFIU_RELEASE_ON_FAILURE
return NULL;
}
***************
*** 97,100 ****
--- 110,114 ----
if (myCreateType->ctor==NULL) {
PyErr_SetString(PyExc_TypeError, "The type does not declare a PyCom constructor");
+ POFIU_RELEASE_ON_FAILURE
return NULL;
}
|