[Asterisk-code-review] res_pjsip_diversion: Use static pj_str_t for Diversion header names (...asterisk[16])

Sean Bright asteriskteam at digium.com
Thu Feb 28 10:08:40 CST 2019


Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/11068


Change subject: res_pjsip_diversion: Use static pj_str_t for Diversion header names
......................................................................

res_pjsip_diversion: Use static pj_str_t for Diversion header names

PJSIP assumes that these header names are not allocated, and does not
clone the name strings when reusing headers.

Block unload of res_pjsip_diversion until shutdown to ensure static
memory stays valid.

ASTERISK-28312 #close

Change-Id: Ibd6ea55ec4a604bbd43ac07f8d0b54da2c39b8b9
---
M res/res_pjsip_diversion.c
1 file changed, 2 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/68/11068/1

diff --git a/res/res_pjsip_diversion.c b/res/res_pjsip_diversion.c
index e82140b..a7c31c4 100644
--- a/res/res_pjsip_diversion.c
+++ b/res/res_pjsip_diversion.c
@@ -325,8 +325,7 @@
 
 	hdr = pjsip_from_hdr_create(tdata->pool);
 	hdr->type = PJSIP_H_OTHER;
-	pj_strdup(tdata->pool, &hdr->name, &diversion_name);
-	hdr->sname = hdr->name;
+	hdr->sname = hdr->name = diversion_name;
 
 	name_addr = pjsip_uri_clone(tdata->pool, base);
 	uri = pjsip_uri_get_uri(name_addr->uri);
@@ -411,6 +410,7 @@
 
 static int load_module(void)
 {
+	ast_module_shutdown_ref(ast_module_info->self);
 	ast_sip_session_register_supplement(&diversion_supplement);
 	return AST_MODULE_LOAD_SUCCESS;
 }

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11068
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ibd6ea55ec4a604bbd43ac07f8d0b54da2c39b8b9
Gerrit-Change-Number: 11068
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190228/607ca674/attachment-0001.html>


More information about the asterisk-code-review mailing list