Skip to content

Commit

Permalink
Merge branch 'jn/CHT-1416-Protect-against-init-NSString-with-null-str…
Browse files Browse the repository at this point in the history
…ing-in-MEGAChatMessage_7_3_0' into 'release/v7.3.0'

CHT-1416: Protect against init NSString with null string in MEGAChatMessage

See merge request megachat/MEGAchat!2040
  • Loading branch information
adlonMEGA committed Jan 27, 2025
2 parents 0e2c2b1 + 13fa0ea commit 54c103e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bindings/Objective-C/MEGAChatMessage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,15 @@ - (uint64_t)userHandleAtIndex:(NSUInteger)index {
}

- (NSString *)userNameAtIndex:(NSUInteger)index {
return self.megaChatMessage ? [[NSString alloc] initWithUTF8String:self.megaChatMessage->getUserName((unsigned int)index)] : nil;
if (!self.megaChatMessage) return nil;
const char *ret = self.megaChatMessage->getUserName((unsigned int)index);
return ret ? [[NSString alloc] initWithUTF8String:ret] : nil;
}

- (NSString *)userEmailAtIndex:(NSUInteger)index {
return self.megaChatMessage ? [[NSString alloc] initWithUTF8String:self.megaChatMessage->getUserEmail((unsigned int)index)] : nil;
if (!self.megaChatMessage) return nil;
const char *ret = self.megaChatMessage->getUserEmail((unsigned int)index);
return ret ? [[NSString alloc] initWithUTF8String:ret] : nil;
}

- (BOOL)hasScheduledMeetingChangeForType:(MEGAChatMessageScheduledMeetingChangeType)changeType {
Expand Down

0 comments on commit 54c103e

Please sign in to comment.