Fix memory leaks in redirecting structures in chan_sip.c

Thanks to Richard for pointing this out.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@263810 65c4cc65-6c06-0410-ace0-fbb531ad65f3
certified/1.8.6
Mark Michelson 16 years ago
parent 115f5076f5
commit 2b2439dede

@ -17535,7 +17535,12 @@ static void change_redirecting_information(struct sip_pvt *p, struct sip_request
ast_debug(3, "Got redirecting from name %s\n", redirecting_from_name); ast_debug(3, "Got redirecting from name %s\n", redirecting_from_name);
redirecting->from.name = redirecting_from_name; redirecting->from.name = redirecting_from_name;
} }
redirecting->from.tag = (char *) p->cid_tag; if (!ast_strlen_zero(p->cid_tag)) {
if (redirecting->from.tag) {
ast_free(redirecting->from.tag);
}
redirecting->from.tag = ast_strdup(p->cid_tag);
}
if (!ast_strlen_zero(redirecting_to_number)) { if (!ast_strlen_zero(redirecting_to_number)) {
if (redirecting->to.number) { if (redirecting->to.number) {
ast_free(redirecting->to.number); ast_free(redirecting->to.number);
@ -17929,6 +17934,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
struct ast_party_redirecting redirecting = {{0,},}; struct ast_party_redirecting redirecting = {{0,},};
change_redirecting_information(p, req, &redirecting, FALSE); change_redirecting_information(p, req, &redirecting, FALSE);
ast_channel_queue_redirecting_update(p->owner, &redirecting); ast_channel_queue_redirecting_update(p->owner, &redirecting);
ast_party_redirecting_free(&redirecting);
sip_handle_cc(p, req, AST_CC_CCNR); sip_handle_cc(p, req, AST_CC_CCNR);
} }
check_pendings(p); check_pendings(p);
@ -18902,6 +18908,7 @@ static void handle_response(struct sip_pvt *p, int resp, const char *rest, struc
struct ast_party_redirecting redirecting = {{0,},}; struct ast_party_redirecting redirecting = {{0,},};
change_redirecting_information(p, req, &redirecting, TRUE); change_redirecting_information(p, req, &redirecting, TRUE);
ast_channel_set_redirecting(p->owner, &redirecting); ast_channel_set_redirecting(p->owner, &redirecting);
ast_party_redirecting_free(&redirecting);
} }
/* Fall through */ /* Fall through */
case 486: /* Busy here */ case 486: /* Busy here */
@ -20490,7 +20497,6 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (!p->lastinvite && !req->ignore && !p->owner) { if (!p->lastinvite && !req->ignore && !p->owner) {
/* This is a new invite */ /* This is a new invite */
/* Handle authentication if this is our first invite */ /* Handle authentication if this is our first invite */
struct ast_party_redirecting redirecting = {{0,},};
int cc_recall_core_id = -1; int cc_recall_core_id = -1;
set_pvt_allowed_methods(p, req); set_pvt_allowed_methods(p, req);
res = check_user(p, req, SIP_INVITE, e, XMIT_RELIABLE, sin); res = check_user(p, req, SIP_INVITE, e, XMIT_RELIABLE, sin);
@ -20560,7 +20566,6 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
goto request_invite_cleanup; goto request_invite_cleanup;
} }
gotdest = get_destination(p, NULL, &cc_recall_core_id); /* Get destination right away */ gotdest = get_destination(p, NULL, &cc_recall_core_id); /* Get destination right away */
change_redirecting_information(p, req, &redirecting, FALSE); /*Will return immediately if no Diversion header is present */
extract_uri(p, req); /* Get the Contact URI */ extract_uri(p, req); /* Get the Contact URI */
build_contact(p); /* Build our contact header */ build_contact(p); /* Build our contact header */
@ -20607,9 +20612,12 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
build_route(p, req, 0); build_route(p, req, 0);
if (c) { if (c) {
struct ast_party_redirecting redirecting = { { 0, }, };
/* Pre-lock the call */ /* Pre-lock the call */
ast_channel_lock(c); ast_channel_lock(c);
change_redirecting_information(p, req, &redirecting, FALSE); /*Will return immediately if no Diversion header is present */
ast_channel_set_redirecting(c, &redirecting); ast_channel_set_redirecting(c, &redirecting);
ast_party_redirecting_free(&redirecting);
} }
} }
} else { } else {
@ -20627,6 +20635,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (c) { if (c) {
ast_channel_set_redirecting(c, &redirecting); ast_channel_set_redirecting(c, &redirecting);
} }
ast_party_redirecting_free(&redirecting);
} }
/* Session-Timers */ /* Session-Timers */

Loading…
Cancel
Save