add check for allocation failure

This commit is contained in:
bienvenu%netscape.com 1999-06-30 00:11:02 +00:00
parent bb53422b38
commit 65ea3cd87f
2 changed files with 10 additions and 5 deletions

View File

@ -32,7 +32,7 @@ nsresult
NS_NewMsgFilterService(const nsIID& iid, void **result)
{
nsMsgFilterService *ids = new nsMsgFilterService();
return ids->QueryInterface(iid, result);
return (ids) ? ids->QueryInterface(iid, result) : NS_ERROR_OUT_OF_MEMORY;
}
NS_END_EXTERN_C

View File

@ -556,10 +556,15 @@ NS_IMETHODIMP nsMsgDatabase::OpenMDB(const char *dbName, PRBool create)
{
nsIOFileStream *dbStream = new nsIOFileStream(nsFileSpec(dbName));
PRInt32 bytesRead = dbStream->read(bufFirst512Bytes, sizeof(bufFirst512Bytes));
first512Bytes.mYarn_Fill = bytesRead;
dbStream->close();
delete dbStream;
if (dbStream)
{
PRInt32 bytesRead = dbStream->read(bufFirst512Bytes, sizeof(bufFirst512Bytes));
first512Bytes.mYarn_Fill = bytesRead;
dbStream->close();
delete dbStream;
}
else
return NS_ERROR_OUT_OF_MEMORY;
}
ret = myMDBFactory->CanOpenFilePort(m_mdbEnv, nativeFileName, // the file to investigate
&first512Bytes, &canOpen, &outFormatVersion);