diff options
author | Richard Mudgett <rmudgett@digium.com> | 2015-03-20 19:52:30 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2015-03-20 19:52:30 +0000 |
commit | 6ca98524bfc321c12398df5ed0cac6c7cad3c55c (patch) | |
tree | 7849f898ac1f68840aacfdc43b2930638803feb9 /res/res_pjsip.c | |
parent | 1c090281718bba6a5cee8f573f4dad0e46427496 (diff) |
Audit ast_pjsip_rdata_get_endpoint() usage for ref leaks.
Valgrind found some memory leaks associated with
ast_pjsip_rdata_get_endpoint(). The leaks would manifest when sending
responses to OPTIONS requests, processing MESSAGE requests, and
res_pjsip supplements implementing the incoming_request callback.
* Fix ast_pjsip_rdata_get_endpoint() endpoint ref leaks in
res/res_pjsip.c:supplement_on_rx_request(),
res/res_pjsip/pjsip_options.c:send_options_response(),
res/res_pjsip_messaging.c:rx_data_to_ast_msg(), and
res/res_pjsip_messaging.c:send_response().
* Eliminated RAII_VAR() use with ast_pjsip_rdata_get_endpoint() in
res/res_pjsip_nat.c:nat_on_rx_message().
* Fixed inconsistent but benign return value in
res/res_pjsip/pjsip_options.c:options_on_rx_request().
Review: https://reviewboard.asterisk.org/r/4511/
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433222 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip.c')
-rw-r--r-- | res/res_pjsip.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 376a16e08..1d57a072b 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -3257,8 +3257,13 @@ static pj_bool_t supplement_on_rx_request(pjsip_rx_data *rdata) AST_RWLIST_RDLOCK(&supplements); AST_LIST_TRAVERSE(&supplements, supplement, next) { - if (supplement->incoming_request && does_method_match(&rdata->msg_info.msg->line.req.method.name, supplement->method)) { - supplement->incoming_request(ast_pjsip_rdata_get_endpoint(rdata), rdata); + if (supplement->incoming_request + && does_method_match(&rdata->msg_info.msg->line.req.method.name, supplement->method)) { + struct ast_sip_endpoint *endpoint; + + endpoint = ast_pjsip_rdata_get_endpoint(rdata); + supplement->incoming_request(endpoint, rdata); + ao2_cleanup(endpoint); } } AST_RWLIST_UNLOCK(&supplements); @@ -3274,7 +3279,8 @@ int ast_sip_send_response(pjsip_response_addr *res_addr, pjsip_tx_data *tdata, s AST_RWLIST_RDLOCK(&supplements); AST_LIST_TRAVERSE(&supplements, supplement, next) { - if (supplement->outgoing_response && does_method_match(&cseq->method.name, supplement->method)) { + if (supplement->outgoing_response + && does_method_match(&cseq->method.name, supplement->method)) { supplement->outgoing_response(sip_endpoint, contact, tdata); } } |