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
Родитель b7a0bbc875
Коммит 60b963012f
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -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;
}