mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-07 22:02:12 +08:00
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
This commit is contained in:

committed by
Sébastien Blin

parent
5856cf5a8f
commit
82fb339119
@ -180,7 +180,15 @@ addContactHeader(const std::string& contactHdr, pjsip_tx_data* tdata)
|
||||
JAMI_WARN("Contact header won't be added (empty string)");
|
||||
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);
|
||||
contact->uri = pjsip_parse_uri(tdata->pool,
|
||||
pjContact.ptr,
|
||||
|
Reference in New Issue
Block a user