summaryrefslogtreecommitdiffstats
path: root/mailnews/imap/src
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2019-11-10 19:23:39 -0500
committerMatt A. Tobin <email@mattatobin.com>2019-11-10 19:23:39 -0500
commit993a6bc1d5a668a427a304142ba3620a0307b61a (patch)
tree17285e32b95561dd12db15fd069dcad2ee9df7fe /mailnews/imap/src
parentba48342fa708533e425fa9ad36f5a7b63da04c9c (diff)
downloadUXP-993a6bc1d5a668a427a304142ba3620a0307b61a.tar
UXP-993a6bc1d5a668a427a304142ba3620a0307b61a.tar.gz
UXP-993a6bc1d5a668a427a304142ba3620a0307b61a.tar.lz
UXP-993a6bc1d5a668a427a304142ba3620a0307b61a.tar.xz
UXP-993a6bc1d5a668a427a304142ba3620a0307b61a.zip
Bug 825513 - Fix crash in nsImapProtocol::GetMessageSize() by adding null check for m_runningUrl && m_hostSessionList.
Tag #1273
Diffstat (limited to 'mailnews/imap/src')
-rw-r--r--mailnews/imap/src/nsImapProtocol.cpp53
1 files changed, 21 insertions, 32 deletions
diff --git a/mailnews/imap/src/nsImapProtocol.cpp b/mailnews/imap/src/nsImapProtocol.cpp
index bf00e0206..b671574ac 100644
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -4527,46 +4527,35 @@ void nsImapProtocol::Log(const char *logSubName, const char *extraInfo, const ch
// In 4.5, this posted an event back to libmsg and blocked until it got a response.
// We may still have to do this.It would be nice if we could preflight this value,
// but we may not always know when we'll need it.
-uint32_t nsImapProtocol::GetMessageSize(const char * messageId,
- bool idsAreUids)
+uint32_t nsImapProtocol::GetMessageSize(const char * messageId, bool idsAreUids)
{
const char *folderFromParser = GetServerStateParser().GetSelectedMailboxName();
- if (folderFromParser && messageId)
- {
- char *id = (char *)PR_CALLOC(strlen(messageId) + 1);
- char *folderName;
- uint32_t size;
+ if (!folderFromParser || !messageId || !m_runningUrl || !m_hostSessionList)
+ return 0;
- PL_strcpy(id, messageId);
+ char *folderName = nullptr;
+ uint32_t size;
- nsIMAPNamespace *nsForMailbox = nullptr;
- m_hostSessionList->GetNamespaceForMailboxForHost(GetImapServerKey(), folderFromParser,
- nsForMailbox);
+ nsIMAPNamespace *nsForMailbox = nullptr;
+ m_hostSessionList->GetNamespaceForMailboxForHost(GetImapServerKey(),
+ folderFromParser,
+ nsForMailbox);
+ m_runningUrl->AllocateCanonicalPath(folderFromParser,
+ nsForMailbox
+ ? nsForMailbox->GetDelimiter()
+ : kOnlineHierarchySeparatorUnknown,
+ &folderName);
- if (nsForMailbox)
- m_runningUrl->AllocateCanonicalPath(
- folderFromParser, nsForMailbox->GetDelimiter(),
- &folderName);
- else
- m_runningUrl->AllocateCanonicalPath(
- folderFromParser,kOnlineHierarchySeparatorUnknown,
- &folderName);
+ if (folderName && m_imapMessageSink)
+ m_imapMessageSink->GetMessageSizeFromDB(messageId, &size);
- if (id && folderName)
- {
- if (m_imapMessageSink)
- m_imapMessageSink->GetMessageSizeFromDB(id, &size);
- }
- PR_FREEIF(id);
- PR_FREEIF(folderName);
+ PR_FREEIF(folderName);
- uint32_t rv = 0;
- if (!DeathSignalReceived())
- rv = size;
- return rv;
- }
- return 0;
+ if (DeathSignalReceived())
+ size = 0;
+
+ return size;
}
// message id string utility functions