From 65ea3cd87fbba05478ed53e95dcf7b00bda4100f Mon Sep 17 00:00:00 2001 From: "bienvenu%netscape.com" Date: Wed, 30 Jun 1999 00:11:02 +0000 Subject: [PATCH] add check for allocation failure --- mailnews/base/search/src/nsMsgFilterService.cpp | 2 +- mailnews/db/msgdb/src/nsMsgDatabase.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/mailnews/base/search/src/nsMsgFilterService.cpp b/mailnews/base/search/src/nsMsgFilterService.cpp index 3295a14ff521..27b78f835873 100644 --- a/mailnews/base/search/src/nsMsgFilterService.cpp +++ b/mailnews/base/search/src/nsMsgFilterService.cpp @@ -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 diff --git a/mailnews/db/msgdb/src/nsMsgDatabase.cpp b/mailnews/db/msgdb/src/nsMsgDatabase.cpp index c70f4e1f0614..78acb883dd9b 100644 --- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp +++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp @@ -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);