mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-16 11:45:31 +00:00
add check for allocation failure
This commit is contained in:
parent
bb53422b38
commit
65ea3cd87f
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user