Bug 235643 all _CreatePrintSettings leak on failure

patch by baafie@planet.nl r=timeless sr=bz a=asa
This commit is contained in:
timeless%mozdev.org 2005-06-16 01:39:19 +00:00
Родитель 33b4f10224
Коммит 7c6d1fa65f
2 изменённых файлов: 14 добавлений и 6 удалений

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

@ -67,13 +67,18 @@ nsPrintOptionsX::~nsPrintOptionsX()
nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)
{
nsresult rv;
*_retval = nsnull;
nsPrintSettingsX* printSettings = new nsPrintSettingsX; // does not initially ref count
if (!printSettings)
return NS_ERROR_OUT_OF_MEMORY;
NS_ENSURE_TRUE(printSettings, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*_retval = printSettings); // ref count
rv = printSettings->Init();
if (NS_FAILED(rv))
return rv;
return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts
NS_RELEASE(*_retval);
return rv;
}
/** ---------------------------------------------------

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

@ -62,9 +62,12 @@ nsPrintOptionsWin::~nsPrintOptionsWin()
/* nsIPrintSettings CreatePrintSettings (); */
nsresult nsPrintOptionsWin::_CreatePrintSettings(nsIPrintSettings **_retval)
{
*_retval = nsnull;
nsPrintSettingsWin* printSettings = new nsPrintSettingsWin(); // does not initially ref count
NS_ASSERTION(printSettings, "Can't be NULL!");
NS_ENSURE_TRUE(printSettings, NS_ERROR_OUT_OF_MEMORY);
return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts
NS_ADDREF(*_retval = printSettings); // ref count
return NS_OK;
}