diff --git a/imapjob.cpp b/imapjob.cpp index bdc413626..b484646d0 100644 --- a/imapjob.cpp +++ b/imapjob.cpp @@ -275,15 +275,15 @@ ImapJob::~ImapJob() void ImapJob::slotGetNextMessage() { KMMessage *msg = mMsgList.first(); - KMFolderImap *msgParent = static_cast(msg->storage()); - KMAcctImap *account = msgParent->account(); - if ( msg->UID() == 0 ) + KMFolderImap *msgParent = msg ? static_cast(msg->storage()) : 0; + if ( msg->UID() == 0 || !msgParent ) { // broken message emit messageRetrieved( 0 ); deleteLater(); return; } + KMAcctImap *account = msgParent->account(); KURL url = account->getUrl(); QString path = msgParent->imapPath() + ";UID=" + QString::number(msg->UID()); ImapAccountBase::jobData jd;