mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Fix another memory leak with linphone_address_as_string_uri_only
This commit is contained in:
parent
6950283052
commit
88144bc4b1
8 changed files with 35 additions and 15 deletions
|
|
@ -209,12 +209,16 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
LinphoneAddress *from = [[[notif userInfo] objectForKey:@"from"] pointerValue];
|
||||
ChatModel *chat = [[notif userInfo] objectForKey:@"chat"];
|
||||
if(from != NULL && chat != NULL) {
|
||||
if([[NSString stringWithUTF8String:linphone_address_as_string_uri_only(from)]
|
||||
caseInsensitiveCompare:remoteAddress] == NSOrderedSame) {
|
||||
[chat setRead:[NSNumber numberWithInt:1]];
|
||||
[chat update];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"LinphoneTextReceived" object:self];
|
||||
[tableController addChatEntry:chat];
|
||||
char *fromStr = linphone_address_as_string_uri_only(from);
|
||||
if(fromStr != NULL) {
|
||||
if([[NSString stringWithUTF8String:fromStr]
|
||||
caseInsensitiveCompare:remoteAddress] == NSOrderedSame) {
|
||||
[chat setRead:[NSNumber numberWithInt:1]];
|
||||
[chat update];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"LinphoneTextReceived" object:self];
|
||||
[tableController addChatEntry:chat];
|
||||
}
|
||||
ms_free(fromStr);
|
||||
}
|
||||
} else {
|
||||
[LinphoneLogger logc:LinphoneLoggerWarning format:"Invalid textReceivedEvent"];
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
if(addr != NULL) {
|
||||
BOOL useLinphoneAddress = true;
|
||||
// contact name
|
||||
const char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
if(lAddress) {
|
||||
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]];
|
||||
contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress];
|
||||
|
|
@ -166,6 +166,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
address = [FastAddressBook getContactDisplayName:contact];
|
||||
useLinphoneAddress = false;
|
||||
}
|
||||
ms_free(lAddress);
|
||||
}
|
||||
if(useLinphoneAddress) {
|
||||
const char* lDisplayName = linphone_address_get_display_name(addr);
|
||||
|
|
@ -234,10 +235,11 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
if (addr != NULL) {
|
||||
// contact name
|
||||
const char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
if(lAddress != NULL) {
|
||||
[addressButton setTitle:[NSString stringWithUTF8String:lAddress] forState:UIControlStateNormal];
|
||||
[addressButton setHidden:FALSE];
|
||||
ms_free(lAddress);
|
||||
} else {
|
||||
[addressButton setHidden:TRUE];
|
||||
}
|
||||
|
|
@ -280,7 +282,9 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
addr = callLog->to;
|
||||
}
|
||||
|
||||
const char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
if(lAddress == NULL)
|
||||
return;
|
||||
|
||||
NSString *displayName = nil;
|
||||
if(contact != nil) {
|
||||
|
|
@ -303,6 +307,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[controller call:[NSString stringWithUTF8String:lAddress]];
|
||||
}
|
||||
}
|
||||
ms_free(lAddress);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@
|
|||
if(addr != NULL) {
|
||||
BOOL useLinphoneAddress = true;
|
||||
// contact name
|
||||
const char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
if(lAddress) {
|
||||
address = [NSString stringWithUTF8String:lAddress];
|
||||
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:address];
|
||||
|
|
@ -146,6 +146,7 @@
|
|||
displayName = [FastAddressBook getContactDisplayName:contact];
|
||||
useLinphoneAddress = false;
|
||||
}
|
||||
ms_free(lAddress);
|
||||
}
|
||||
if(useLinphoneAddress) {
|
||||
const char* lDisplayName = linphone_address_get_display_name(addr);
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@
|
|||
if (addr != NULL) {
|
||||
BOOL useLinphoneAddress = true;
|
||||
// contact name
|
||||
const char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
if(lAddress) {
|
||||
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]];
|
||||
ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress];
|
||||
|
|
@ -106,6 +106,7 @@
|
|||
address = [FastAddressBook getContactDisplayName:contact];
|
||||
useLinphoneAddress = false;
|
||||
}
|
||||
ms_free(lAddress);
|
||||
}
|
||||
if(useLinphoneAddress) {
|
||||
const char* lDisplayName = linphone_address_get_display_name(addr);
|
||||
|
|
|
|||
|
|
@ -330,15 +330,21 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo
|
|||
|
||||
- (void)onTextReceived:(LinphoneCore *)lc room:(LinphoneChatRoom *)room from:(const LinphoneAddress *)from message:(const char *)message {
|
||||
|
||||
char *fromStr = linphone_address_as_string_uri_only(from);
|
||||
if(fromStr == NULL)
|
||||
return;
|
||||
|
||||
// Save message in database
|
||||
ChatModel *chat = [[ChatModel alloc] init];
|
||||
[chat setRemoteContact:[NSString stringWithUTF8String:linphone_address_as_string_uri_only(from)]];
|
||||
[chat setRemoteContact:[NSString stringWithUTF8String:fromStr]];
|
||||
[chat setMessage:[NSString stringWithUTF8String:message]];
|
||||
[chat setDirection:[NSNumber numberWithInt:1]];
|
||||
[chat setTime:[NSDate date]];
|
||||
[chat setRead:[NSNumber numberWithInt:0]];
|
||||
[chat create];
|
||||
|
||||
ms_free(fromStr);
|
||||
|
||||
// Post event
|
||||
NSDictionary* dict = [[[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
[NSValue valueWithPointer:room], @"room",
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@
|
|||
if(addr != NULL) {
|
||||
BOOL useLinphoneAddress = true;
|
||||
// contact name
|
||||
const char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
if(lAddress) {
|
||||
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]];
|
||||
ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress];
|
||||
|
|
@ -180,6 +180,7 @@
|
|||
address = [FastAddressBook getContactDisplayName:contact];
|
||||
useLinphoneAddress = false;
|
||||
}
|
||||
ms_free(lAddress);
|
||||
}
|
||||
if(useLinphoneAddress) {
|
||||
const char* lDisplayName = linphone_address_get_display_name(addr);
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@
|
|||
if(addr != NULL) {
|
||||
BOOL useLinphoneAddress = true;
|
||||
// contact name
|
||||
const char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
if(lAddress) {
|
||||
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]];
|
||||
ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress];
|
||||
|
|
@ -126,6 +126,7 @@
|
|||
address = [FastAddressBook getContactDisplayName:contact];
|
||||
useLinphoneAddress = false;
|
||||
}
|
||||
ms_free(lAddress);
|
||||
}
|
||||
if(useLinphoneAddress) {
|
||||
const char* lDisplayName = linphone_address_get_display_name(addr);
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@ static PhoneMainView* phoneMainViewInstance=nil;
|
|||
if(addr != NULL) {
|
||||
BOOL useLinphoneAddress = true;
|
||||
// contact name
|
||||
const char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
if(lAddress) {
|
||||
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]];
|
||||
ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress];
|
||||
|
|
@ -491,6 +491,7 @@ static PhoneMainView* phoneMainViewInstance=nil;
|
|||
address = [FastAddressBook getContactDisplayName:contact];
|
||||
useLinphoneAddress = false;
|
||||
}
|
||||
ms_free(lAddress);
|
||||
}
|
||||
if(useLinphoneAddress) {
|
||||
const char* lDisplayName = linphone_address_get_display_name(addr);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue