Index: src/vortex_connection.c =================================================================== --- src/vortex_connection.c (revision 688) +++ src/vortex_connection.c (revision 689) @@ -37,6 +37,7 @@ */ /* global include */ +#include #include /* private include */ @@ -2118,6 +2119,7 @@ /* decrease reference counting */ connection->ref_count--; + assert( connection->ref_count >= 0 ); vortex_log (LOG_DOMAIN, VORTEX_LEVEL_DEBUG, "decreased connection id=%d reference count to %d decreased by %s", connection->id, Index: src/vortex_channel.c =================================================================== --- src/vortex_channel.c (revision 688) +++ src/vortex_channel.c (revision 689) @@ -35,7 +35,7 @@ * Email address: * info@aspl.es - http://www.aspl.es/vortex */ - +#include #define LOG_DOMAIN "vortex-channel" /** @@ -3970,6 +3970,7 @@ /* decrease the channel */ channel->ref_count--; + assert( channel->ref_count >= 0 ); vortex_log (LOG_DOMAIN, VORTEX_LEVEL_DEBUG, "channel=%d unref called, ref count status after calling=%d", channel->channel_num, channel->ref_count); Index: src/vortex_frame_factory.c =================================================================== --- src/vortex_frame_factory.c (revision 688) +++ src/vortex_frame_factory.c (revision 689) @@ -35,6 +35,7 @@ * Email address: * info@aspl.es - http://www.aspl.es/vortex */ +#include #include /* local include */ @@ -143,6 +144,7 @@ /* check reference counting */ vortex_mutex_lock (&status->ref_mutex); status->ref_count--; + assert( status->ref_count >= 0 ); if (status->ref_count != 0) { /* this caller won't terminate this mime status */ vortex_mutex_unlock (&status->ref_mutex); @@ -1748,7 +1750,8 @@ /* decrease reference counting */ frame->ref_count--; - + assert( frame->ref_count >= 0 ); + /* check and dealloc */ if (frame->ref_count == 0) { vortex_frame_free (frame); Index: src/vortex_hash.c =================================================================== --- src/vortex_hash.c (revision 688) +++ src/vortex_hash.c (revision 689) @@ -35,6 +35,7 @@ * Email address: * info@aspl.es - http://www.aspl.es/vortex */ +#include #include #define LOG_DOMAIN "vortex-hash" @@ -500,6 +501,7 @@ /* reduce reference counting */ hash_table->ref_count--; + assert( hash_table->ref_count >= 0 ); if (hash_table->ref_count != 0) { /* unlock the mutex and returns: more callers have a * referece to this hash */