fixed leaked service manager in nsPluginFactory

This commit is contained in:
warren%netscape.com 1999-09-20 20:53:06 +00:00
parent cf2623c425
commit 0d13aa6282
2 changed files with 10 additions and 12 deletions

View File

@ -18,7 +18,7 @@
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsCOMPtr.h"
//#include "nsPluginsCID.h"
#include "nsPluginHostImpl.h"
@ -158,12 +158,11 @@ NSGetFactory(nsISupports* serviceMgr,
return NS_ERROR_NULL_POINTER;
}
nsIServiceManager *pnsIServiceManager = NULL;
if (NS_FAILED(serviceMgr->QueryInterface(kIServiceManagerIID, (void**) &pnsIServiceManager)))
return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr = do_QueryInterface(serviceMgr, &rv);
if (NS_FAILED(rv)) return rv;
*aFactory = new nsPluginFactory(aClass, pnsIServiceManager);
serviceMgr->Release();
*aFactory = new nsPluginFactory(aClass, servMgr);
if (nsnull == aFactory) {
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -18,7 +18,7 @@
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsCOMPtr.h"
//#include "nsPluginsCID.h"
#include "nsPluginHostImpl.h"
@ -158,12 +158,11 @@ NSGetFactory(nsISupports* serviceMgr,
return NS_ERROR_NULL_POINTER;
}
nsIServiceManager *pnsIServiceManager = NULL;
if (NS_FAILED(serviceMgr->QueryInterface(kIServiceManagerIID, (void**) &pnsIServiceManager)))
return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr = do_QueryInterface(serviceMgr, &rv);
if (NS_FAILED(rv)) return rv;
*aFactory = new nsPluginFactory(aClass, pnsIServiceManager);
serviceMgr->Release();
*aFactory = new nsPluginFactory(aClass, servMgr);
if (nsnull == aFactory) {
return NS_ERROR_OUT_OF_MEMORY;