зеркало из https://github.com/mozilla/gecko-dev.git
Fix a couple of memory leaks. Not part of the default build.
This commit is contained in:
Родитель
b8ca55ad08
Коммит
77f69277a4
|
@ -135,7 +135,9 @@ static PyObject *GetAsInterface(PyObject *self, PyObject *args) {
|
||||||
nsIID *iid;
|
nsIID *iid;
|
||||||
nsresult nr = pI->GetAsInterface(&iid, getter_AddRefs(p));
|
nsresult nr = pI->GetAsInterface(&iid, getter_AddRefs(p));
|
||||||
if (NS_FAILED(nr)) return PyXPCOM_BuildPyException(nr);
|
if (NS_FAILED(nr)) return PyXPCOM_BuildPyException(nr);
|
||||||
return Py_nsISupports::PyObjectFromInterface(p, *iid);
|
PyObject *ret = Py_nsISupports::PyObjectFromInterface(p, *iid);
|
||||||
|
nsMemory::Free(iid);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *GetAsISupports(PyObject *self, PyObject *args) {
|
static PyObject *GetAsISupports(PyObject *self, PyObject *args) {
|
||||||
|
|
|
@ -877,6 +877,7 @@ PyObject_FromVariant( Py_nsISupports *parent, nsIVariant *v)
|
||||||
// If the variant itself holds a variant, we should
|
// If the variant itself holds a variant, we should
|
||||||
// probably unpack that too?
|
// probably unpack that too?
|
||||||
ret = parent->MakeInterfaceResult(p, *iid);
|
ret = parent->MakeInterfaceResult(p, *iid);
|
||||||
|
nsMemory::Free((char*)iid);
|
||||||
break;
|
break;
|
||||||
// case nsIDataType::VTYPE_WCHAR_STR
|
// case nsIDataType::VTYPE_WCHAR_STR
|
||||||
// case nsIDataType::VTYPE_UTF8STRING
|
// case nsIDataType::VTYPE_UTF8STRING
|
||||||
|
@ -2109,6 +2110,7 @@ PyObject *PyXPCOM_GatewayVariantHelper::MakeSingleParam(int index, PythonTypeDes
|
||||||
}
|
}
|
||||||
PRUint32 seq_size = GetSizeIs(index, PR_FALSE);
|
PRUint32 seq_size = GetSizeIs(index, PR_FALSE);
|
||||||
ret = UnpackSingleArray(NULL, t, seq_size, array_type&XPT_TDP_TAGMASK, piid);
|
ret = UnpackSingleArray(NULL, t, seq_size, array_type&XPT_TDP_TAGMASK, piid);
|
||||||
|
nsMemory::Free(piid);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2147,6 +2149,7 @@ PyObject *PyXPCOM_GatewayVariantHelper::MakeSingleParam(int index, PythonTypeDes
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Caller must free iid when no longer needed.
|
||||||
nsresult PyXPCOM_GatewayVariantHelper::GetArrayType(PRUint8 index, PRUint8 *ret, nsIID **iid)
|
nsresult PyXPCOM_GatewayVariantHelper::GetArrayType(PRUint8 index, PRUint8 *ret, nsIID **iid)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIInterfaceInfoManager> iim(do_GetService(
|
nsCOMPtr<nsIInterfaceInfoManager> iim(do_GetService(
|
||||||
|
@ -2165,11 +2168,13 @@ nsresult PyXPCOM_GatewayVariantHelper::GetArrayType(PRUint8 index, PRUint8 *ret,
|
||||||
if (NS_FAILED(rc))
|
if (NS_FAILED(rc))
|
||||||
return rc;
|
return rc;
|
||||||
if (iid) {
|
if (iid) {
|
||||||
*iid = (nsIID *)&NS_GET_IID(nsISupports);
|
|
||||||
if (XPT_TDP_TAG(datumType)==nsXPTType::T_INTERFACE ||
|
if (XPT_TDP_TAG(datumType)==nsXPTType::T_INTERFACE ||
|
||||||
XPT_TDP_TAG(datumType)==nsXPTType::T_INTERFACE_IS ||
|
XPT_TDP_TAG(datumType)==nsXPTType::T_INTERFACE_IS ||
|
||||||
XPT_TDP_TAG(datumType)==nsXPTType::T_ARRAY)
|
XPT_TDP_TAG(datumType)==nsXPTType::T_ARRAY)
|
||||||
ii->GetIIDForParam(m_method_index, ¶m_info, iid);
|
ii->GetIIDForParam(m_method_index, ¶m_info, iid);
|
||||||
|
else
|
||||||
|
*iid = (nsIID*) nsMemory::Clone(&NS_GET_IID(nsISupports),
|
||||||
|
sizeof(nsIID));
|
||||||
}
|
}
|
||||||
*ret = datumType.flags;
|
*ret = datumType.flags;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -2428,7 +2433,9 @@ nsresult PyXPCOM_GatewayVariantHelper::BackFillVariant( PyObject *val, int index
|
||||||
// We do allow NULL here, even tho doing so will no-doubt crash some objects.
|
// We do allow NULL here, even tho doing so will no-doubt crash some objects.
|
||||||
// (but there will certainly be objects out there that will allow NULL :-(
|
// (but there will certainly be objects out there that will allow NULL :-(
|
||||||
nsIID iid_use = iid ? *iid : NS_GET_IID(nsISupports);
|
nsIID iid_use = iid ? *iid : NS_GET_IID(nsISupports);
|
||||||
if (!Py_nsISupports::InterfaceFromPyObject(val, iid_use, &pnew, PR_TRUE))
|
PRBool ok = Py_nsISupports::InterfaceFromPyObject(val, iid_use, &pnew, PR_TRUE);
|
||||||
|
nsMemory::Free(iid);
|
||||||
|
if (!ok)
|
||||||
BREAK_FALSE;
|
BREAK_FALSE;
|
||||||
nsISupports **pp = (nsISupports **)ns_v.val.p;
|
nsISupports **pp = (nsISupports **)ns_v.val.p;
|
||||||
if (*pp && pi->IsIn()) {
|
if (*pp && pi->IsIn()) {
|
||||||
|
@ -2571,8 +2578,7 @@ nsresult PyXPCOM_GatewayVariantHelper::BackFillVariant( PyObject *val, int index
|
||||||
// If it is an existing array of the correct size, keep it.
|
// If it is an existing array of the correct size, keep it.
|
||||||
PRUint32 sequence_size = 0;
|
PRUint32 sequence_size = 0;
|
||||||
PRUint8 array_type;
|
PRUint8 array_type;
|
||||||
nsIID *piid;
|
nsresult ns = GetArrayType(index, &array_type, NULL);
|
||||||
nsresult ns = GetArrayType(index, &array_type, &piid);
|
|
||||||
if (NS_FAILED(ns))
|
if (NS_FAILED(ns))
|
||||||
return ns;
|
return ns;
|
||||||
PRUint32 element_size = GetArrayElementSize(array_type);
|
PRUint32 element_size = GetArrayElementSize(array_type);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче