Commit a7529424 authored by Simon Morlat's avatar Simon Morlat

fix regression in object reference counting

parent 7cedd5e5
...@@ -111,22 +111,23 @@ belle_sip_object_t * belle_sip_object_ref(void *obj){ ...@@ -111,22 +111,23 @@ belle_sip_object_t * belle_sip_object_ref(void *obj){
void belle_sip_object_unref(void *ptr){ void belle_sip_object_unref(void *ptr){
belle_sip_object_t *obj=BELLE_SIP_OBJECT(ptr); belle_sip_object_t *obj=BELLE_SIP_OBJECT(ptr);
if (obj->ref==-1) { if (obj->ref <= -1) {
belle_sip_error("Object [%p] freed twice !",obj); belle_sip_error("Object [%p] freed twice or corrupted !",obj);
if (obj->vptr && obj->vptr->type_name) belle_sip_error("Object type might be [%s]",obj->vptr->type_name); if (obj->vptr && obj->vptr->type_name) belle_sip_error("Object type might be [%s]",obj->vptr->type_name);
if (obj->name) belle_sip_error("Object name might be [%s]",obj->name); if (obj->name) belle_sip_error("Object name might be [%s]",obj->name);
belle_sip_fatal("Fatal object error encountered, aborting."); belle_sip_fatal("Fatal object error encountered, aborting.");
return; return;
} }
if (obj->ref==0 && obj->pool){ if (obj->vptr->initially_unowned && obj->ref==0){
belle_sip_object_pool_remove(obj->pool,obj); if (obj->pool)
belle_sip_object_pool_remove(obj->pool,obj);
obj->ref=-1; obj->ref=-1;
belle_sip_object_delete(obj); belle_sip_object_delete(obj);
return; return;
} }
obj->ref--; obj->ref--;
if (obj->ref<=0){ // Can be null OR negative when no pool is available and object is unowned if (obj->ref == 0){
obj->ref=-1; obj->ref = -1;
belle_sip_object_delete(obj); belle_sip_object_delete(obj);
} }
} }
......
...@@ -417,7 +417,7 @@ int belle_sip_verify_cb_error_wrapper(x509_crt *cert, int depth, int *flags){ ...@@ -417,7 +417,7 @@ int belle_sip_verify_cb_error_wrapper(x509_crt *cert, int depth, int *flags){
memcpy(der, cert->raw.p, cert->raw.len); memcpy(der, cert->raw.p, cert->raw.len);
der[cert->raw.len] = '\0'; der[cert->raw.len] = '\0';
rc = tls_verify_cb_error_cb(der, cert->raw.len, depth, flags); rc = tls_verify_cb_error_cb(der, cert->raw.len, depth, flags);
belle_sip_message("belle_sip_verify_cb_error_wrapper: callback return rc: %d, flags: %d", rc, *flags); belle_sip_message("belle_sip_verify_cb_error_wrapper: callback return rc: %d, flags: %d", rc, *flags);
belle_sip_free(der); belle_sip_free(der);
......
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