diff options
author | 2013-06-20 11:19:31 -0500 | |
---|---|---|
committer | 2013-06-20 11:19:31 -0500 | |
commit | 999425a99c31f00d90644253aea6ab4a7c2f34b7 (patch) | |
tree | 3208611de20b5063e31180b85e6f78e1d8ab99dd | |
parent | 00129b3b39ff076f3925d550dff3580e4854a43f (diff) |
Added more checks for NULL fields in recipientWithReplyAll
-rw-r--r-- | src/core/abstract/MCMessageHeader.cc | 80 |
1 files changed, 42 insertions, 38 deletions
diff --git a/src/core/abstract/MCMessageHeader.cc b/src/core/abstract/MCMessageHeader.cc index 3a2a5872..3ac69b2b 100644 --- a/src/core/abstract/MCMessageHeader.cc +++ b/src/core/abstract/MCMessageHeader.cc @@ -1076,48 +1076,52 @@ Array * MessageHeader::recipientWithReplyAll(bool replyAll, bool includeTo, bool Array * recipient; recipient = new Array(); - for(unsigned int i = 0 ; i < to()->count() ; i ++) { - Address * address = (Address *) to()->objectAtIndex(i); - if (addedAddresses->containsObject(address->mailbox()->lowercaseString())) { - continue; - } - if (address->mailbox()->isEqualCaseInsensitive(from()->mailbox())) { - recipient->addObjectsFromArray(replyTo()); - for(unsigned int j = 0 ; j < to()->count() ; j ++) { - Address * address = (Address *) replyTo()->objectAtIndex(j); - if (addedAddresses->containsObject(address->mailbox()->lowercaseString())) { - continue; - } - if (address->mailbox() == NULL) - continue; - addedAddresses->addObject(address->mailbox()->lowercaseString()); - } - } - else { - if (address->mailbox() != NULL) { - recipient->addObject(address); - addedAddresses->addObject(address->mailbox()->lowercaseString()); - } - } - hasTo = true; - } + if (to() != NULL && to()->count() > 0) { + for(unsigned int i = 0 ; i < to()->count() ; i ++) { + Address * address = (Address *) to()->objectAtIndex(i); + if (addedAddresses->containsObject(address->mailbox()->lowercaseString())) { + continue; + } + if (address->mailbox()->isEqualCaseInsensitive(from()->mailbox())) { + recipient->addObjectsFromArray(replyTo()); + for(unsigned int j = 0 ; j < to()->count() ; j ++) { + Address * address = (Address *) replyTo()->objectAtIndex(j); + if (addedAddresses->containsObject(address->mailbox()->lowercaseString())) { + continue; + } + if (address->mailbox() == NULL) + continue; + addedAddresses->addObject(address->mailbox()->lowercaseString()); + } + } + else { + if (address->mailbox() != NULL) { + recipient->addObject(address); + addedAddresses->addObject(address->mailbox()->lowercaseString()); + } + } + hasTo = true; + } + } toField = recipient; toField->retain()->autorelease(); recipient->release(); if (replyAll) { recipient = new Array(); - for(unsigned int i = 0 ; i < cc()->count() ; i ++) { - Address * address = (Address *) cc()->objectAtIndex(i); - if (addedAddresses->containsObject(address->mailbox()->lowercaseString())) { - continue; - } - if (address->mailbox() == NULL) - continue; - recipient->addObject(address); - addedAddresses->addObject(address->mailbox()->lowercaseString()); - hasCc = true; - } + if (cc() != NULL && cc()->count() > 0) { + for(unsigned int i = 0 ; i < cc()->count() ; i ++) { + Address * address = (Address *) cc()->objectAtIndex(i); + if (addedAddresses->containsObject(address->mailbox()->lowercaseString())) { + continue; + } + if (address->mailbox() == NULL) + continue; + recipient->addObject(address); + addedAddresses->addObject(address->mailbox()->lowercaseString()); + hasCc = true; + } + } ccField = recipient; ccField->retain()->autorelease(); recipient->release(); @@ -1153,7 +1157,7 @@ Array * MessageHeader::recipientWithReplyAll(bool replyAll, bool includeTo, bool Array * recipient; recipient = new Array(); - if (to() != NULL) { + if (to() != NULL && to()->count() > 0) { for(unsigned int i = 0 ; i < to()->count() ; i ++) { Address * address = (Address *) to()->objectAtIndex(i); if (addedAddresses->containsObject(address->mailbox()->lowercaseString())) { @@ -1165,7 +1169,7 @@ Array * MessageHeader::recipientWithReplyAll(bool replyAll, bool includeTo, bool addedAddresses->addObject(address->mailbox()->lowercaseString()); } } - if (cc() != NULL) { + if (cc() != NULL && cc()->count() > 0) { for(unsigned int i = 0 ; i < cc()->count() ; i ++) { Address * address = (Address *) cc()->objectAtIndex(i); if (addedAddresses->containsObject(address->mailbox()->lowercaseString())) { |