From 379ac0e21ec6ab4255733b59c7712b3745775b4b Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 11 Jan 2016 11:46:02 +0100 Subject: [PATCH] Fixed a leak of LinphoneAddress and replaced some linphone_address_destroy by linphone_address_unref --- coreapi/carddav.c | 21 ++++++++++----------- coreapi/friend.c | 13 +++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/coreapi/carddav.c b/coreapi/carddav.c index 4f4c904de..e871b51bc 100644 --- a/coreapi/carddav.c +++ b/coreapi/carddav.c @@ -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); return; } - if (query->depth) { - 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); - } - } + req = belle_http_request_create(query->method, uri, belle_sip_header_content_type_create("application", "xml; charset=utf-8"), NULL); + if (!req) { LinphoneCardDavContext *cdc = query->context; if (cdc && cdc->sync_done_cb) { @@ -412,6 +403,14 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) { 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) { 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); diff --git a/coreapi/friend.c b/coreapi/friend.c index 4bb0e7448..773b9e78e 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -143,7 +143,7 @@ LinphoneFriend *linphone_friend_new_with_address(const char *addr){ } fr=linphone_friend_new(); linphone_friend_set_address(fr,linphone_address); - linphone_address_destroy(linphone_address); + linphone_address_unref(linphone_address); return fr; } @@ -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_username(id,uri); *result=linphone_address_as_string(id); - linphone_address_destroy(id); + linphone_address_unref(id); } } if (*result){ @@ -191,7 +191,7 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char } }else { *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) LinphoneVCard *vcard = NULL; 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; vcard = linphone_friend_get_vcard(lf); @@ -318,7 +318,7 @@ static void _linphone_friend_release_ops(LinphoneFriend *lf){ static void _linphone_friend_destroy(LinphoneFriend *lf){ _linphone_friend_release_ops(lf); 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->vcard != NULL) linphone_vcard_free(lf->vcard); } @@ -857,7 +857,7 @@ LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVCard *vcard) { linphone_address = linphone_address_new(sipAddress); if (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); @@ -1032,6 +1032,7 @@ static int create_friend(void *data, int argc, char **argv, char **colName) { LinphoneAddress *addr = linphone_address_new(argv[1]); lf = linphone_friend_new(); linphone_friend_set_address(lf, addr); + linphone_address_unref(addr); } linphone_friend_set_inc_subscribe_policy(lf, atoi(argv[2])); linphone_friend_send_subscribe(lf, atoi(argv[3]));