From: <do...@us...> - 2008-06-11 22:25:18
|
Revision: 1434 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1434&view=rev Author: dohpaz Date: 2008-06-11 15:25:26 -0700 (Wed, 11 Jun 2008) Log Message: ----------- Add some additional protection on shutdown by making sure to set max_calls to 0. Also initialize max_calls to 0, and calls to NULL to allow condom code to work. Modified Paths: -------------- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c Modified: branches/team/elbunce/iaxclient/lib/iaxclient_lib.c =================================================================== --- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2008-06-04 14:03:56 UTC (rev 1433) +++ branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2008-06-11 22:25:26 UTC (rev 1434) @@ -108,8 +108,8 @@ int iaxci_audio_output_mode = 0; // Normal int selected_call; // XXX to be protected by mutex? -struct iaxc_call* calls; -int max_calls; // number of calls for this library session +struct iaxc_call* calls = NULL; +int max_calls = 0; // number of calls for this library session static void service_network(); static int service_audio(); @@ -691,7 +691,7 @@ /* destroy enocders and decoders for all existing calls */ if ( calls ) { - int i; + int i; for ( i=0 ; i<max_calls ; i++ ) { if ( calls[i].encoder ) @@ -702,17 +702,23 @@ calls[i].vencoder->destroy(calls[i].vencoder); if ( calls[i].vdecoder ) calls[i].vdecoder->destroy(calls[i].vdecoder); - } + } + + /* Since we're de-initialized the maximum number of calls is 0, + this lets the calls size checks handle + array validity for us. ;-) + */ + max_calls = 0; + free(calls); calls = NULL; } + put_iaxc_lock(); #ifdef WIN32 closesocket(iax_get_fd()); //fd: #endif - free(calls); - MUTEXDESTROY(&event_queue_lock); MUTEXDESTROY(&iaxc_lock); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |