Commit 379ac0e2 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Fixed a leak of LinphoneAddress and replaced some linphone_address_destroy by...

Fixed a leak of LinphoneAddress and replaced some linphone_address_destroy by linphone_address_unref
parent 2a85a54f
...@@ -391,17 +391,8 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) { ...@@ -391,17 +391,8 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
belle_sip_error("Could not send request, URL %s is invalid", query->url); belle_sip_error("Could not send request, URL %s is invalid", query->url);
return; return;
} }
if (query->depth) { req = belle_http_request_create(query->method, uri, belle_sip_header_content_type_create("application", "xml; charset=utf-8"), NULL);
req = belle_http_request_create(query->method, uri, belle_sip_header_content_type_create("application", "xml; charset=utf-8"), belle_sip_header_create("Depth", query->depth), NULL);
} else if (query->ifmatch) {
req = belle_http_request_create(query->method, uri, belle_sip_header_content_type_create("application", "xml; charset=utf-8"), belle_sip_header_create("If-Match", query->ifmatch), NULL);
} else {
if (strcmp(query->method, "PUT")) {
req = belle_http_request_create(query->method, uri, belle_sip_header_content_type_create("application", "xml; charset=utf-8"), belle_sip_header_create("If-None-Match", "*"), NULL);
} else {
req = belle_http_request_create(query->method, uri, belle_sip_header_content_type_create("application", "xml; charset=utf-8"), NULL);
}
}
if (!req) { if (!req) {
LinphoneCardDavContext *cdc = query->context; LinphoneCardDavContext *cdc = query->context;
if (cdc && cdc->sync_done_cb) { if (cdc && cdc->sync_done_cb) {
...@@ -412,6 +403,14 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) { ...@@ -412,6 +403,14 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
return; return;
} }
if (query->depth) {
belle_sip_message_add_header((belle_sip_message_t *)req, belle_sip_header_create("Depth", query->depth));
} else if (query->ifmatch) {
belle_sip_message_add_header((belle_sip_message_t *)req, belle_sip_header_create("If-Match", query->ifmatch));
} else if (strcmp(query->method, "PUT")) {
belle_sip_message_add_header((belle_sip_message_t *)req, belle_sip_header_create("If-None-Match", "*"));
}
if (query->body) { if (query->body) {
bh = belle_sip_memory_body_handler_new_copy_from_buffer(query->body, strlen(query->body), NULL, NULL); bh = belle_sip_memory_body_handler_new_copy_from_buffer(query->body, strlen(query->body), NULL, NULL);
belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(req), bh ? BELLE_SIP_BODY_HANDLER(bh) : NULL); belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(req), bh ? BELLE_SIP_BODY_HANDLER(bh) : NULL);
......
...@@ -143,7 +143,7 @@ LinphoneFriend *linphone_friend_new_with_address(const char *addr){ ...@@ -143,7 +143,7 @@ LinphoneFriend *linphone_friend_new_with_address(const char *addr){
} }
fr=linphone_friend_new(); fr=linphone_friend_new();
linphone_friend_set_address(fr,linphone_address); linphone_friend_set_address(fr,linphone_address);
linphone_address_destroy(linphone_address); linphone_address_unref(linphone_address);
return fr; return fr;
} }
...@@ -180,7 +180,7 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char ...@@ -180,7 +180,7 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char
linphone_address_set_display_name(id,NULL); linphone_address_set_display_name(id,NULL);
linphone_address_set_username(id,uri); linphone_address_set_username(id,uri);
*result=linphone_address_as_string(id); *result=linphone_address_as_string(id);
linphone_address_destroy(id); linphone_address_unref(id);
} }
} }
if (*result){ if (*result){
...@@ -191,7 +191,7 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char ...@@ -191,7 +191,7 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char
} }
}else { }else {
*result=linphone_address_as_string(fr); *result=linphone_address_as_string(fr);
linphone_address_destroy(fr); linphone_address_unref(fr);
} }
} }
...@@ -200,7 +200,7 @@ int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr) ...@@ -200,7 +200,7 @@ int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr)
LinphoneVCard *vcard = NULL; LinphoneVCard *vcard = NULL;
linphone_address_clean(fr); linphone_address_clean(fr);
if (lf->uri != NULL) linphone_address_destroy(lf->uri); if (lf->uri != NULL) linphone_address_unref(lf->uri);
lf->uri = fr; lf->uri = fr;
vcard = linphone_friend_get_vcard(lf); vcard = linphone_friend_get_vcard(lf);
...@@ -318,7 +318,7 @@ static void _linphone_friend_release_ops(LinphoneFriend *lf){ ...@@ -318,7 +318,7 @@ static void _linphone_friend_release_ops(LinphoneFriend *lf){
static void _linphone_friend_destroy(LinphoneFriend *lf){ static void _linphone_friend_destroy(LinphoneFriend *lf){
_linphone_friend_release_ops(lf); _linphone_friend_release_ops(lf);
if (lf->presence != NULL) linphone_presence_model_unref(lf->presence); if (lf->presence != NULL) linphone_presence_model_unref(lf->presence);
if (lf->uri!=NULL) linphone_address_destroy(lf->uri); if (lf->uri!=NULL) linphone_address_unref(lf->uri);
if (lf->info!=NULL) buddy_info_free(lf->info); if (lf->info!=NULL) buddy_info_free(lf->info);
if (lf->vcard != NULL) linphone_vcard_free(lf->vcard); if (lf->vcard != NULL) linphone_vcard_free(lf->vcard);
} }
...@@ -857,7 +857,7 @@ LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVCard *vcard) { ...@@ -857,7 +857,7 @@ LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVCard *vcard) {
linphone_address = linphone_address_new(sipAddress); linphone_address = linphone_address_new(sipAddress);
if (linphone_address) { if (linphone_address) {
linphone_friend_set_address(fr, linphone_address); linphone_friend_set_address(fr, linphone_address);
linphone_address_destroy(linphone_address); linphone_address_unref(linphone_address);
} }
} }
linphone_friend_set_name(fr, name); linphone_friend_set_name(fr, name);
...@@ -1032,6 +1032,7 @@ static int create_friend(void *data, int argc, char **argv, char **colName) { ...@@ -1032,6 +1032,7 @@ static int create_friend(void *data, int argc, char **argv, char **colName) {
LinphoneAddress *addr = linphone_address_new(argv[1]); LinphoneAddress *addr = linphone_address_new(argv[1]);
lf = linphone_friend_new(); lf = linphone_friend_new();
linphone_friend_set_address(lf, addr); linphone_friend_set_address(lf, addr);
linphone_address_unref(addr);
} }
linphone_friend_set_inc_subscribe_policy(lf, atoi(argv[2])); linphone_friend_set_inc_subscribe_policy(lf, atoi(argv[2]));
linphone_friend_send_subscribe(lf, atoi(argv[3])); linphone_friend_send_subscribe(lf, atoi(argv[3]));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment