Commit 66d3946f authored by Guillaume Roguez's avatar Guillaume Roguez

sipcall: invalid invite when not used by call

This patchset fixes a sigfault due to usage of call pointer
embeeded inside the invite C struture, used by many PJSIP events
callbacks.

Refs #67940

Change-Id: Ie15946cf4d2859e8ce97ec382a4abc43a0f63bb3
parent b4bea220
......@@ -131,14 +131,7 @@ SIPCall::SIPCall(SIPAccountBase& account, const std::string& id, Call::CallType
SIPCall::~SIPCall()
{
const auto mod_ua_id = getSIPVoIPLink()->getModId();
// prevent this from getting accessed in callbacks
// RING_WARN: this is not thread-safe!
if (inv && inv->mod_data[mod_ua_id]) {
RING_WARN("Call was not properly removed from invite callbacks");
inv->mod_data[mod_ua_id] = nullptr;
}
inv.reset(); // prevents callback usage
}
SIPAccountBase&
......@@ -944,4 +937,12 @@ SIPCall::setSecure(bool sec)
srtpEnabled_ = sec;
}
void
SIPCall::InvSessionDeleter::operator ()(pjsip_inv_session* inv) const noexcept
{
// prevent this from getting accessed in callbacks
// RING_WARN: this is not thread-safe!
inv->mod_data[getSIPVoIPLink()->getModId()] = nullptr;
}
} // namespace ring
......@@ -116,8 +116,11 @@ class SIPCall : public Call
/**
* The invite session to be reused in case of transfer
*/
struct InvSessionDeleter { void operator()(pjsip_inv_session*) {} };
std::unique_ptr<pjsip_inv_session, InvSessionDeleter> inv {};
struct InvSessionDeleter {
void operator()(pjsip_inv_session*) const noexcept;
};
std::unique_ptr<pjsip_inv_session, InvSessionDeleter> inv;
void setSecure(bool sec);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment