Commit 887b41c9 authored by Simon Morlat's avatar Simon Morlat

Fix double release() of Sal::Op in a rare case where a LinphoneFriend is...

Fix double release() of Sal::Op in a rare case where a LinphoneFriend is detached from its FriendList.
parent 03e7eecf
......@@ -1993,8 +1993,11 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, Sa
}
}else{
ms_message("But this person is not part of our friend list, so we don't care.");
/*
* This case may happen when a friend has been removed from FriendList, in which case it its presence is no longer managed.
* We don't have to release() or unref() the op, because it is still hold by the detached LinphoneFriend.
*/
linphone_presence_model_unref(presence);
op->release();
return ;
}
if (ss==SalSubscribeTerminated){
......
......@@ -203,6 +203,10 @@ void SalOp::killDialog () {
}
void SalOp::release () {
if (mOpReleased){
lError() << "op [" << this << "]: double release detected and ignored.";
return;
}
// If in terminating state, keep this state because it means we are waiting for a response to be able to terminate the operation
if (mState != State::Terminating)
mState = State::Terminated;
......
......@@ -119,6 +119,7 @@ public:
}
int refresh ();
void killDialog ();
//Release means let the op finish its life but we don't want to use it anymore, and don't want to be called in callbacks for this op
void release ();
virtual void authenticate (const SalAuthInfo *info) {
......
......@@ -168,12 +168,20 @@ SalPresenceModel *SalPresenceOp::processPresenceNotification (belle_sip_request_
}
void SalPresenceOp::handleNotify (belle_sip_request_t *request, belle_sip_dialog_t *dialog) {
belle_sip_response_t *response = nullptr;
if (strcmp("NOTIFY", belle_sip_request_get_method(request)) != 0)
return;
if (mDialog && (dialog != mDialog)) {
lWarning() << "Receiving a NOTIFY from a dialog we haven't stored (op->dialog=" << mDialog << " dialog=" << dialog;
}
if (dialog == nullptr){
lError() << "Out of dialog presence notify are not allowed.";
response = createResponseFromRequest(request, 481);
belle_sip_server_transaction_send_response(mPendingServerTransaction, response);
return;
}
SalSubscribeStatus subscriptionState;
auto subscriptionStateHeader = belle_sip_message_get_header_by_type(
......@@ -190,7 +198,7 @@ void SalPresenceOp::handleNotify (belle_sip_request_t *request, belle_sip_dialog
}
ref(); // Take a ref because the notify_presence callback may release the op
belle_sip_response_t *response = nullptr;
const char *body = belle_sip_message_get_body(BELLE_SIP_MESSAGE(request));
auto presenceModel = processPresenceNotification(request);
if (presenceModel || !body) {
......
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