From 6ca98524bfc321c12398df5ed0cac6c7cad3c55c Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Fri, 20 Mar 2015 19:52:30 +0000 Subject: 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 --- res/res_pjsip_nat.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'res/res_pjsip_nat.c') diff --git a/res/res_pjsip_nat.c b/res/res_pjsip_nat.c index b71a84bbd..6e093abcd 100644 --- a/res/res_pjsip_nat.c +++ b/res/res_pjsip_nat.c @@ -72,8 +72,13 @@ static pj_bool_t handle_rx_message(struct ast_sip_endpoint *endpoint, pjsip_rx_d static pj_bool_t nat_on_rx_message(pjsip_rx_data *rdata) { - RAII_VAR(struct ast_sip_endpoint *, endpoint, ast_pjsip_rdata_get_endpoint(rdata), ao2_cleanup); - return handle_rx_message(endpoint, rdata); + pj_bool_t res; + struct ast_sip_endpoint *endpoint; + + endpoint = ast_pjsip_rdata_get_endpoint(rdata); + res = handle_rx_message(endpoint, rdata); + ao2_cleanup(endpoint); + return res; } /*! \brief Structure which contains information about a transport */ -- cgit v1.2.3