From f1a9d3be1344ec3813670883dbb43fe541a74379 Mon Sep 17 00:00:00 2001 From: David Bienvenu Date: Thu, 24 Jun 2010 07:24:31 -0700 Subject: [PATCH] fix bug 562104, crash when subscribed to imap folder '/', r/sr=standard8 --- mailnews/imap/src/nsImapIncomingServer.cpp | 5 ++++- mailnews/imap/test/unit/test_mailboxes.js | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mailnews/imap/src/nsImapIncomingServer.cpp b/mailnews/imap/src/nsImapIncomingServer.cpp index a36d14846c..f9f9b8ebb8 100644 --- a/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mailnews/imap/src/nsImapIncomingServer.cpp @@ -1057,6 +1057,8 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const nsACString& folder if (dupFolderPath.Last() == '/') { dupFolderPath.SetLength(dupFolderPath.Length()-1); + if (dupFolderPath.IsEmpty()) + return NS_ERROR_FAILURE; // *** this is what we did in 4.x in order to list uw folder only // mailbox in order to get the \NoSelect flag explicitlyVerify = !(boxFlags & kNameSpace); @@ -1165,7 +1167,8 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const nsACString& folder (kPublicMailbox | kOtherUsersMailbox | kPersonalMailbox))), &parentIsNew); } } - hostFolder->CreateClientSubfolderInfo(dupFolderPath, hierarchyDelimiter,boxFlags, PR_FALSE); + rv = hostFolder->CreateClientSubfolderInfo(dupFolderPath, hierarchyDelimiter,boxFlags, PR_FALSE); + NS_ENSURE_SUCCESS(rv, rv); caseInsensitive = MsgLowerCaseEqualsLiteral(dupFolderPath, "inbox"); a_nsIFolder->GetChildWithURI(uri, PR_TRUE, caseInsensitive, getter_AddRefs(child)); } diff --git a/mailnews/imap/test/unit/test_mailboxes.js b/mailnews/imap/test/unit/test_mailboxes.js index e179d99a3e..22ece4c3a6 100644 --- a/mailnews/imap/test/unit/test_mailboxes.js +++ b/mailnews/imap/test/unit/test_mailboxes.js @@ -59,6 +59,16 @@ const gTestArray = QueryInterface(Ci.nsIMsgImapMailFolder); newChild.updateFolderWithListener(null, UrlListener); }, + function checkEmptyFolder() { + try { + let serverSink = gLocalServer.QueryInterface(Ci.nsIImapServerSink); + serverSink.possibleImapMailbox("/", '/', 0); + } + catch (ex) { + // we expect this to fail, but not crash or assert. + } + do_timeout_function(0, function(){doTest(++gCurTestNum)}); + }, ]; function endTest() @@ -80,7 +90,7 @@ function doTest(test) var testFn = gTestArray[test-1]; // Set a limit of 10 seconds; if the notifications haven't arrived by then there's a problem. - do_timeout(10000, function(){ + do_timeout_function(10000, function(){ if (gCurTestNum == test) do_throw("Notifications not received in 10000 ms for operation " + testFn.name + ", current status is " + gCurrStatus); @@ -113,6 +123,6 @@ var UrlListener = // This can happen with a bunch of synchronous functions grouped together, and // can even cause tests to fail because they're still waiting for the listener // to return - do_timeout(0, function(){doTest(++gCurTestNum)}); + do_timeout_function(0, function(){doTest(++gCurTestNum)}); } };