]> sjero.net Git - linphone/commitdiff
protect osip_list_set_empty()
authorSimon Morlat <simon.morlat@linphone.org>
Fri, 25 Mar 2011 13:39:39 +0000 (14:39 +0100)
committerSimon Morlat <simon.morlat@linphone.org>
Fri, 25 Mar 2011 13:39:39 +0000 (14:39 +0100)
fix spurious "no response" errors at end of calls

coreapi/sal_eXosip2.c
coreapi/sal_eXosip2.h

index 38638716e5a78176e2005fcd1823484b94a9aec6..1c04eb190bb934079d52c56f21aaeaf00ce18a65 100644 (file)
@@ -30,9 +30,10 @@ static void text_received(Sal *sal, eXosip_event_t *ev);
 
 void _osip_list_set_empty(osip_list_t *l, void (*freefunc)(void*)){
        void *data;
-       while((data=osip_list_get(l,0))!=NULL){
+       while(!osip_list_eol(l,0)) {
+               data=osip_list_get(l,0);
                osip_list_remove(l,0);
-               freefunc(data);
+               if (data) freefunc(data);
        }
 }
 
@@ -168,6 +169,7 @@ SalOp * sal_op_new(Sal *sal){
        op->masquerade_via=FALSE;
        op->auto_answer_asked=FALSE;
        op->auth_info=NULL;
+       op->terminated=FALSE;
        return op;
 }
 
@@ -778,6 +780,7 @@ int sal_call_terminate(SalOp *h){
        if (err!=0){
                ms_warning("Exosip could not terminate the call: cid=%i did=%i", h->cid,h->did);
        }
+       h->terminated=TRUE;
        return 0;
 }
 
@@ -1004,6 +1007,7 @@ static int call_proceeding(Sal *sal, eXosip_event_t *ev){
                eXosip_lock();
                eXosip_call_terminate(ev->cid,ev->did);
                eXosip_unlock();
+               op->terminated=TRUE;
                return -1;
        }
        if (ev->did>0)
@@ -1080,6 +1084,7 @@ static void call_terminated(Sal *sal, eXosip_event_t *ev){
        }
        sal->callbacks.call_terminated(op,from!=NULL ? from : sal_op_get_from(op));
        if (from) osip_free(from);
+       op->terminated=TRUE;
 }
 
 static void call_released(Sal *sal, eXosip_event_t *ev){
@@ -1088,7 +1093,7 @@ static void call_released(Sal *sal, eXosip_event_t *ev){
                ms_warning("No op associated to this call_released()");
                return;
        }
-       if (ev->response==NULL){
+       if (!op->terminated){
                /* no response received so far */
                call_failure(sal,ev);
        }
@@ -1871,8 +1876,14 @@ int sal_register(SalOp *h, const char *proxy, const char *from, int expires){
        if (h->rid==-1){
                eXosip_lock();
                h->rid=eXosip_register_build_initial_register(from,proxy,NULL,expires,&msg);
-               if (contact) register_set_contact(msg,contact);
-               sal_add_register(h->base.root,h);
+               if (msg){
+                       if (contact) register_set_contact(msg,contact);
+                       sal_add_register(h->base.root,h);
+               }else{
+                       ms_error("Could not build initial register.");
+                       eXosip_unlock();
+                       return -1;
+               }
        }else{
                eXosip_lock();
                eXosip_register_build_register(h->rid,expires,&msg);    
index 4db203362f589ee021ad3da7f76add64e0a8702d..d55263627b126be99d18c0f7993c7ff7994aef21 100644 (file)
@@ -65,6 +65,7 @@ struct SalOp{
        bool_t reinvite;
        bool_t masquerade_via;
        bool_t auto_answer_asked;
+       bool_t terminated;
        const SalAuthInfo *auth_info;
 };