mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 20:46:28 +00:00
More leaks fixed
This commit is contained in:
parent
ae313e7020
commit
a3b3867a6c
4 changed files with 46 additions and 22 deletions
|
|
@ -102,6 +102,9 @@ static int find_matching_friend(LinphoneFriend *lf1, LinphoneFriend *lf2) {
|
|||
}
|
||||
|
||||
static void linphone_carddav_response_free(LinphoneCardDavResponse *response) {
|
||||
if (response->etag) ms_free(response->etag);
|
||||
if (response->url) ms_free(response->url);
|
||||
if (response->vcard) ms_free(response->vcard);
|
||||
ms_free(response);
|
||||
}
|
||||
|
||||
|
|
@ -343,6 +346,13 @@ static void linphone_carddav_query_free(LinphoneCardDavQuery *query) {
|
|||
// Context will be freed later (in sync_done)
|
||||
query->context = NULL;
|
||||
|
||||
if (query->url) {
|
||||
ms_free(query->url);
|
||||
}
|
||||
if (query->body) {
|
||||
ms_free(query->body);
|
||||
}
|
||||
|
||||
ms_free(query);
|
||||
}
|
||||
|
||||
|
|
@ -404,7 +414,7 @@ static void process_response_from_carddav_request(void *data, const belle_http_r
|
|||
// We need to do a GET on the vCard to get the correct one
|
||||
bctbx_list_t *vcard = NULL;
|
||||
LinphoneCardDavResponse *response = (LinphoneCardDavResponse *)ms_new0(LinphoneCardDavResponse, 1);
|
||||
response->url = linphone_vcard_get_url(lvc);
|
||||
response->url = ms_strdup(linphone_vcard_get_url(lvc));
|
||||
vcard = bctbx_list_append(vcard, response);
|
||||
linphone_carddav_pull_vcards(query->context, vcard);
|
||||
bctbx_list_free_with_data(vcard, (void (*)(void *))linphone_carddav_response_free);
|
||||
|
|
@ -551,9 +561,9 @@ static LinphoneCardDavQuery* linphone_carddav_create_put_query(LinphoneCardDavCo
|
|||
query->context = cdc;
|
||||
query->depth = NULL;
|
||||
query->ifmatch = linphone_vcard_get_etag(lvc);
|
||||
query->body = linphone_vcard_as_vcard4_string(lvc);
|
||||
query->body = ms_strdup(linphone_vcard_as_vcard4_string(lvc));
|
||||
query->method = "PUT";
|
||||
query->url = linphone_vcard_get_url(lvc);
|
||||
query->url = ms_strdup(linphone_vcard_get_url(lvc));
|
||||
query->type = LinphoneCardDavQueryTypePut;
|
||||
return query;
|
||||
}
|
||||
|
|
@ -625,7 +635,7 @@ static LinphoneCardDavQuery* linphone_carddav_create_delete_query(LinphoneCardDa
|
|||
query->ifmatch = linphone_vcard_get_etag(lvc);
|
||||
query->body = NULL;
|
||||
query->method = "DELETE";
|
||||
query->url = linphone_vcard_get_url(lvc);
|
||||
query->url = ms_strdup(linphone_vcard_get_url(lvc));
|
||||
query->type = LinphoneCardDavQueryTypeDelete;
|
||||
return query;
|
||||
}
|
||||
|
|
@ -693,9 +703,9 @@ static LinphoneCardDavQuery* linphone_carddav_create_propfind_query(LinphoneCard
|
|||
query->context = cdc;
|
||||
query->depth = "0";
|
||||
query->ifmatch = NULL;
|
||||
query->body = "<d:propfind xmlns:d=\"DAV:\" xmlns:cs=\"http://calendarserver.org/ns/\"><d:prop><cs:getctag /></d:prop></d:propfind>";
|
||||
query->body = ms_strdup("<d:propfind xmlns:d=\"DAV:\" xmlns:cs=\"http://calendarserver.org/ns/\"><d:prop><cs:getctag /></d:prop></d:propfind>");
|
||||
query->method = "PROPFIND";
|
||||
query->url = cdc->friend_list->uri;
|
||||
query->url = ms_strdup(cdc->friend_list->uri);
|
||||
query->type = LinphoneCardDavQueryTypePropfind;
|
||||
return query;
|
||||
}
|
||||
|
|
@ -710,9 +720,9 @@ static LinphoneCardDavQuery* linphone_carddav_create_addressbook_query(LinphoneC
|
|||
query->context = cdc;
|
||||
query->depth = "1";
|
||||
query->ifmatch = NULL;
|
||||
query->body = "<card:addressbook-query xmlns:d=\"DAV:\" xmlns:card=\"urn:ietf:params:xml:ns:carddav\"><d:prop><d:getetag /></d:prop><card:filter></card:filter></card:addressbook-query>";
|
||||
query->body = ms_strdup("<card:addressbook-query xmlns:d=\"DAV:\" xmlns:card=\"urn:ietf:params:xml:ns:carddav\"><d:prop><d:getetag /></d:prop><card:filter></card:filter></card:addressbook-query>");
|
||||
query->method = "REPORT";
|
||||
query->url = cdc->friend_list->uri;
|
||||
query->url = ms_strdup(cdc->friend_list->uri);
|
||||
query->type = LinphoneCardDavQueryTypeAddressbookQuery;
|
||||
return query;
|
||||
}
|
||||
|
|
@ -731,7 +741,7 @@ static LinphoneCardDavQuery* linphone_carddav_create_addressbook_multiget_query(
|
|||
query->depth = "1";
|
||||
query->ifmatch = NULL;
|
||||
query->method = "REPORT";
|
||||
query->url = cdc->friend_list->uri;
|
||||
query->url = ms_strdup(cdc->friend_list->uri);
|
||||
query->type = LinphoneCardDavQueryTypeAddressbookMultiget;
|
||||
|
||||
sprintf(body, "%s", "<card:addressbook-multiget xmlns:d=\"DAV:\" xmlns:card=\"urn:ietf:params:xml:ns:carddav\"><d:prop><d:getetag /><card:address-data content-type='text/vcard' version='4.0'/></d:prop>");
|
||||
|
|
|
|||
|
|
@ -220,7 +220,9 @@ int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr)
|
|||
|
||||
vcard = lf->vcard;
|
||||
if (vcard) {
|
||||
linphone_vcard_edit_main_sip_address(vcard, linphone_address_as_string_uri_only(fr));
|
||||
char *address = linphone_address_as_string_uri_only(fr);
|
||||
linphone_vcard_edit_main_sip_address(vcard, address);
|
||||
ms_free(address);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -228,6 +230,8 @@ int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr)
|
|||
|
||||
void linphone_friend_add_address(LinphoneFriend *lf, const LinphoneAddress *addr) {
|
||||
LinphoneVcard *vcard = NULL;
|
||||
char *address = NULL;
|
||||
|
||||
if (!lf || !addr) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -242,7 +246,9 @@ void linphone_friend_add_address(LinphoneFriend *lf, const LinphoneAddress *addr
|
|||
return;
|
||||
}
|
||||
|
||||
linphone_vcard_add_sip_address(vcard, linphone_address_as_string_uri_only(addr));
|
||||
address = linphone_address_as_string_uri_only(addr);
|
||||
linphone_vcard_add_sip_address(vcard, address);
|
||||
ms_free(address);
|
||||
}
|
||||
|
||||
bctbx_list_t* linphone_friend_get_addresses(LinphoneFriend *lf) {
|
||||
|
|
@ -276,6 +282,7 @@ bctbx_list_t* linphone_friend_get_addresses(LinphoneFriend *lf) {
|
|||
|
||||
void linphone_friend_remove_address(LinphoneFriend *lf, const LinphoneAddress *addr) {
|
||||
LinphoneVcard *vcard = NULL;
|
||||
char * address = NULL;
|
||||
if (!lf || !addr) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -284,8 +291,10 @@ void linphone_friend_remove_address(LinphoneFriend *lf, const LinphoneAddress *a
|
|||
if (!vcard) {
|
||||
return;
|
||||
}
|
||||
|
||||
linphone_vcard_remove_sip_address(vcard, linphone_address_as_string_uri_only(addr));
|
||||
|
||||
address = linphone_address_as_string_uri_only(addr);
|
||||
linphone_vcard_remove_sip_address(vcard, address);
|
||||
ms_free(address);
|
||||
}
|
||||
|
||||
void linphone_friend_add_phone_number(LinphoneFriend *lf, const char *phone) {
|
||||
|
|
@ -444,6 +453,7 @@ static void _linphone_friend_destroy(LinphoneFriend *lf){
|
|||
if (lf->uri!=NULL) linphone_address_unref(lf->uri);
|
||||
if (lf->info!=NULL) buddy_info_free(lf->info);
|
||||
if (lf->vcard != NULL) linphone_vcard_free(lf->vcard);
|
||||
if (lf->refkey != NULL) ms_free(lf->refkey);
|
||||
}
|
||||
|
||||
static belle_sip_error_code _linphone_friend_marshall(belle_sip_object_t *obj, char* buff, size_t buff_size, size_t *offset) {
|
||||
|
|
@ -1563,15 +1573,18 @@ void linphone_core_migrate_friends_from_rc_to_db(LinphoneCore *lc) {
|
|||
const LinphoneAddress *addr = linphone_friend_get_address(lf);
|
||||
if (addr) {
|
||||
const char *displayName = linphone_address_get_display_name(addr);
|
||||
char *address = NULL;
|
||||
if (!displayName) {
|
||||
displayName = linphone_address_get_username(addr);
|
||||
}
|
||||
|
||||
address = linphone_address_as_string(addr);
|
||||
if (!linphone_friend_create_vcard(lf, displayName)) {
|
||||
ms_warning("Couldn't create vCard for friend %s", linphone_address_as_string(addr));
|
||||
ms_warning("Couldn't create vCard for friend %s", address);
|
||||
} else {
|
||||
linphone_vcard_add_sip_address(linphone_friend_get_vcard(lf), linphone_address_as_string_uri_only(addr));
|
||||
linphone_vcard_add_sip_address(linphone_friend_get_vcard(lf), address);
|
||||
}
|
||||
ms_free(address);
|
||||
|
||||
linphone_friend_list_add_friend(lfl, lf);
|
||||
linphone_friend_unref(lf);
|
||||
|
|
|
|||
|
|
@ -1308,9 +1308,9 @@ struct _LinphoneCardDavContext {
|
|||
|
||||
struct _LinphoneCardDavQuery {
|
||||
LinphoneCardDavContext *context;
|
||||
const char *url;
|
||||
char *url;
|
||||
const char *method;
|
||||
const char *body;
|
||||
char *body;
|
||||
const char *depth;
|
||||
const char *ifmatch;
|
||||
belle_http_request_listener_t *http_request_listener;
|
||||
|
|
@ -1319,9 +1319,9 @@ struct _LinphoneCardDavQuery {
|
|||
};
|
||||
|
||||
struct _LinphoneCardDavResponse {
|
||||
const char *etag;
|
||||
const char *url;
|
||||
const char *vcard;
|
||||
char *etag;
|
||||
char *url;
|
||||
char *vcard;
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ static LinphoneVcard* linphone_vcard_new_from_belcard(shared_ptr<belcard::BelCar
|
|||
|
||||
void linphone_vcard_free(LinphoneVcard *vCard) {
|
||||
if (!vCard) return;
|
||||
|
||||
if (vCard->etag) ms_free(vCard->etag);
|
||||
if (vCard->url) ms_free(vCard->url);
|
||||
vCard->belCard.reset();
|
||||
ms_free(vCard);
|
||||
}
|
||||
|
|
@ -240,7 +241,7 @@ bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard) {
|
|||
if (sal_generate_uuid(uuid, sizeof(uuid)) == 0) {
|
||||
char vcard_uuid[sizeof(uuid)+4];
|
||||
snprintf(vcard_uuid, sizeof(vcard_uuid), "urn:%s", uuid);
|
||||
linphone_vcard_set_uid(vCard, ms_strdup(vcard_uuid));
|
||||
linphone_vcard_set_uid(vCard, vcard_uuid);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue