From ae730520de60d4c5ffc5c160037907b5f5fed4df Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Tue, 2 Jan 2001 05:27:13 +0000 Subject: [PATCH] add null pointer checks to avoid crashing during history commit - avoid crash described in bug 62968 r=blake (no sr= cuz it's so freakin simple) git-svn-id: svn://10.0.0.236/trunk@84259 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpfe/components/history/src/nsGlobalHistory.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp index a3f32c7541c..a2054d1f6c2 100644 --- a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp +++ b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp @@ -1752,6 +1752,10 @@ nsGlobalHistory::OpenExistingFile(nsIMdbFactory *factory, const char *filePath) mdbOid oid = { kToken_HistoryRowScope, 1 }; err = mStore->GetTable(mEnv, &oid, &mTable); NS_ENSURE_TRUE(err == 0, NS_ERROR_FAILURE); + if (!mTable) { + NS_WARNING("Your history file is somehow corrupt.. deleting it."); + return NS_ERROR_FAILURE; + } return NS_OK; } @@ -1780,6 +1784,7 @@ nsGlobalHistory::OpenNewFile(nsIMdbFactory *factory, const char *filePath) // Create the one and only table in the history db err = mStore->NewTable(mEnv, kToken_HistoryRowScope, kToken_HistoryKind, PR_TRUE, nsnull, &mTable); if (err != 0) return NS_ERROR_FAILURE; + if (!mTable) return NS_ERROR_FAILURE; // Force a commit now to get it written out. nsMdbPtr thumb(mEnv); @@ -1841,8 +1846,8 @@ nsresult nsGlobalHistory::Commit(eCommitType commitType) nsresult err = NS_OK; nsMdbPtr thumb(mEnv); - if (!mStore) - return NS_ERROR_NULL_POINTER; + if (!mStore || !mTable) + return NS_ERROR_NOT_INITIALIZED; if (commitType == kLargeCommit || commitType == kSessionCommit) {