Commit 4c6b700d authored by jehan's avatar jehan

fix possible invalid read in object_unref function

parent a029446d
......@@ -141,14 +141,17 @@ void belle_sip_object_unref(void *ptr){
return;
}
obj->ref--;
if (obj->vptr->on_last_ref){
if ((obj->vptr->initially_unowned && obj->ref==0)
|| (!obj->vptr->initially_unowned && obj->ref == 1)){
if ((obj->vptr->initially_unowned && obj->ref==1)
|| (!obj->vptr->initially_unowned && obj->ref == 2)){
obj->vptr->on_last_ref(obj);
}
}
obj->ref--; /* keep the ref until here to make sure obj is not deleted by obj->vptr->on_last_ref*/
if (obj->ref == 0){
obj->ref = -1;
belle_sip_object_delete(obj);
......
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