summaryrefslogtreecommitdiff
path: root/res/res_pjsip/pjsip_options.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2015-03-20 19:54:48 +0000
committerRichard Mudgett <rmudgett@digium.com>2015-03-20 19:54:48 +0000
commit7e097bce8687256ee400347245b7956c8e2fc452 (patch)
tree81e35595ba890ac19447dd73536822918d83b4fe /res/res_pjsip/pjsip_options.c
parent148e8799fefb48fd324ce9b8813d1919ba72a8fd (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/ ........ Merged revisions 433222 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433223 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip/pjsip_options.c')
-rw-r--r--res/res_pjsip/pjsip_options.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index 44f33f321..0b14bed92 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -609,17 +609,20 @@ static pj_status_t send_options_response(pjsip_rx_data *rdata, int code)
if (dlg && trans) {
status = pjsip_dlg_send_response(dlg, trans, tdata);
} else {
- /* Get where to send request. */
- if ((status = pjsip_get_response_addr(
- tdata->pool, rdata, &res_addr)) != PJ_SUCCESS) {
- ast_log(LOG_ERROR, "Unable to get response address (%d)\n",
- status);
+ struct ast_sip_endpoint *endpoint;
+
+ /* Get where to send response. */
+ status = pjsip_get_response_addr(tdata->pool, rdata, &res_addr);
+ if (status != PJ_SUCCESS) {
+ ast_log(LOG_ERROR, "Unable to get response address (%d)\n", status);
pjsip_tx_data_dec_ref(tdata);
return status;
}
- status = ast_sip_send_response(&res_addr, tdata,
- ast_pjsip_rdata_get_endpoint(rdata));
+
+ endpoint = ast_pjsip_rdata_get_endpoint(rdata);
+ status = ast_sip_send_response(&res_addr, tdata, endpoint);
+ ao2_cleanup(endpoint);
}
if (status != PJ_SUCCESS) {
@@ -648,7 +651,7 @@ static pj_bool_t options_on_rx_request(pjsip_rx_data *rdata)
ruri = rdata->msg_info.msg->line.req.uri;
if (!PJSIP_URI_SCHEME_IS_SIP(ruri) && !PJSIP_URI_SCHEME_IS_SIPS(ruri)) {
send_options_response(rdata, 416);
- return -1;
+ return PJ_TRUE;
}
sip_ruri = pjsip_uri_get_uri(ruri);