From 2809c1d417029074d298e52d61edf7e78e96bc80 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Mon, 24 Mar 2014 19:34:54 -0700 Subject: Fixed potential crash (fixed #658) --- src/core/imap/MCIMAPSession.cc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index b387e48f..ea3f7462 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -1431,19 +1431,21 @@ Array * /* IMAPFolder */ IMAPSession::fetchAllFolders(ErrorCode * pError) if (* pError == ErrorConnection) mShouldDisconnect = true; - bool hasInbox = false; - mc_foreacharray(IMAPFolder, folder, result) { - if (folder->path()->isEqual(MCSTR("INBOX"))) { - hasInbox = true; + if (result != NULL) { + bool hasInbox = false; + mc_foreacharray(IMAPFolder, folder, result) { + if (folder->path()->isEqual(MCSTR("INBOX"))) { + hasInbox = true; + } + } + + if (!hasInbox) { + r = mailimap_list(mImap, "", "INBOX", &imap_folders); + Array * inboxResult = resultsWithError(r, imap_folders, pError); + if (* pError == ErrorConnection) + mShouldDisconnect = true; + result->addObjectsFromArray(inboxResult); } - } - - if (!hasInbox) { - r = mailimap_list(mImap, "", "INBOX", &imap_folders); - Array * inboxResult = resultsWithError(r, imap_folders, pError); - if (* pError == ErrorConnection) - mShouldDisconnect = true; - result->addObjectsFromArray(inboxResult); } return result; -- cgit v1.2.3