Bug 695138 - Fix inout memory leak in XPConnect tests. r=khuey

This commit is contained in:
Bobby Holley 2011-10-27 12:43:38 -07:00
parent 25e13ac102
commit 014266f77f

View File

@ -131,6 +131,11 @@ NS_IMETHODIMP nsXPCTestParams::TestString(const char * a, char * *b NS_INOUTPARA
nsDependentCString bprime(*b);
*_retval = ToNewCString(bprime);
*b = ToNewCString(aprime);
// XPCOM ownership rules dictate that overwritten inout params must be callee-freed.
// See https://developer.mozilla.org/en/XPIDL
NS_Free(const_cast<char*>(bprime.get()));
return NS_OK;
}
@ -147,6 +152,11 @@ NS_IMETHODIMP nsXPCTestParams::TestWstring(const PRUnichar * a, PRUnichar * *b N
nsDependentString bprime(*b);
*_retval = ToNewUnicode(bprime);
*b = ToNewUnicode(aprime);
// XPCOM ownership rules dictate that overwritten inout params must be callee-freed.
// See https://developer.mozilla.org/en/XPIDL
NS_Free(const_cast<PRUnichar*>(bprime.get()));
return NS_OK;
}