Bug 1187410 - Use GetNameShared() in XPCNativeInterface::NewInstance() to avoid a leak. r=mrbkap

GetName() returns a new string, but that string is never freed.

This patch avoids the leak by not copying the string. This is okay because
the scope of intfNameChars is within the scope of aInfo.
This commit is contained in:
Andrew McCreight 2015-07-26 14:26:23 -07:00
parent 2ee305ed5c
commit c44d10db45

View File

@ -239,8 +239,8 @@ XPCNativeInterface::NewInstance(nsIInterfaceInfo* aInfo)
if (mainProcessScriptableOnly && !XRE_IsParentProcess()) {
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (console) {
char* intfNameChars;
aInfo->GetName(&intfNameChars);
const char* intfNameChars;
aInfo->GetNameShared(&intfNameChars);
nsPrintfCString errorMsg("Use of %s in content process is deprecated.", intfNameChars);
nsAutoString filename;