Permalink
Browse files

Merge pull request #64 from ghdk/InvalidMailMessageDereferences

Protects the dereferences of the struct mailmessage *myMessage.
  • Loading branch information...
2 parents b74d05f + d9a69fe commit 28aa229fdd1ef66422194cf386f246b30d4e956f @mronge mronge committed Mar 14, 2013
Showing with 5 additions and 5 deletions.
  1. +5 −5 Source/CTCoreMessage.m
@@ -408,7 +408,7 @@ - (NSDate *)senderDate {
}
- (BOOL)isUnread {
- struct mail_flags *flags = myMessage->msg_flags;
+ struct mail_flags *flags = myMessage ? myMessage->msg_flags : NULL;
if (flags != NULL) {
BOOL flag_seen = (flags->fl_flags & MAIL_FLAG_SEEN);
return !flag_seen;
@@ -417,7 +417,7 @@ - (BOOL)isUnread {
}
- (BOOL)isStarred {
- struct mail_flags *flags = myMessage->msg_flags;
+ struct mail_flags *flags = myMessage ? myMessage->msg_flags : NULL;
if (flags != NULL) {
BOOL flag_starred = (flags->fl_flags & MAIL_FLAG_FLAGGED);
return flag_starred;
@@ -426,7 +426,7 @@ - (BOOL)isStarred {
}
- (BOOL)isNew {
- struct mail_flags *flags = myMessage->msg_flags;
+ struct mail_flags *flags = myMessage ? myMessage->msg_flags : NULL;
if (flags != NULL) {
BOOL flag_seen = (flags->fl_flags & MAIL_FLAG_SEEN);
BOOL flag_new = (flags->fl_flags & MAIL_FLAG_NEW);
@@ -444,7 +444,7 @@ - (NSString *)messageId {
}
- (NSUInteger)uid {
- if (myMessage->msg_uid) {
+ if (myMessage && myMessage->msg_uid) {
NSString *uidString = [[NSString alloc] initWithCString:myMessage->msg_uid encoding:NSASCIIStringEncoding];
NSUInteger uid = (NSUInteger)[[[uidString componentsSeparatedByString:@"-"] objectAtIndex:1] intValue];
[uidString release];
@@ -645,7 +645,7 @@ - (NSData *)messageAsEmlx {
[emlx appendData:msgContentAsData];
- struct mail_flags *flagsStruct = myMessage->msg_flags;
+ struct mail_flags *flagsStruct = myMessage ? myMessage->msg_flags : NULL;
uint64_t flags = 0;
if (flagsStruct != NULL) {
BOOL seen = (flagsStruct->fl_flags & CTFlagSeen) > 0;

0 comments on commit 28aa229

Please sign in to comment.