Skip to content
Snippets Groups Projects
Commit 82fb3391 authored by Olivier Dion's avatar Olivier Dion Committed by Sébastien Blin
Browse files

sip/sip_utils: Duplicate contact header

pjsip scans the contact header but keep a string view of it internally instead of
copying it.  Thus, duplicate the contact header and bind its lifetime to the
pool allocator of the tdata structure.

Gitlab: #668

Change-Id: Ief31fcc6033b394dcb43ee0403f9459654d29f1f
parent 5856cf5a
Branches
No related tags found
No related merge requests found
...@@ -180,7 +180,15 @@ addContactHeader(const std::string& contactHdr, pjsip_tx_data* tdata) ...@@ -180,7 +180,15 @@ addContactHeader(const std::string& contactHdr, pjsip_tx_data* tdata)
JAMI_WARN("Contact header won't be added (empty string)"); JAMI_WARN("Contact header won't be added (empty string)");
return; return;
} }
auto pjContact = sip_utils::CONST_PJ_STR(contactHdr);
/*
* Duplicate contact header because tdata->msg keep a reference to it and
* can be used in a callback after destruction of the contact header in
* Jami. Bind lifetime of the duplicated string to the pool allocator of
* tdata.
*/
auto pjContact = pj_strdup3(tdata->pool, contactHdr.c_str());
pjsip_contact_hdr* contact = pjsip_contact_hdr_create(tdata->pool); pjsip_contact_hdr* contact = pjsip_contact_hdr_create(tdata->pool);
contact->uri = pjsip_parse_uri(tdata->pool, contact->uri = pjsip_parse_uri(tdata->pool,
pjContact.ptr, pjContact.ptr,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment