alsa: fixed Segmentation fault due to dangling pointer left by snd_lib_error_set_handler() call which set callback pointer to ALSA during PaAlsa_Initialize call. Segmentation fault happens only if application dynamically unloaded PortAudio while still using ALSA through other means, then next ALSA error which causes invocation of ALSA error handling callbacks would cause Segmentation fault. Bug reported in: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=563192, and re-announced by Phil Burk on 15.10.2010.
This commit is contained in:
parent
e47e43deb8
commit
96b86da500
1 changed files with 13 additions and 3 deletions
|
|
@ -239,9 +239,12 @@ static const PaAlsaDeviceInfo *GetDeviceInfo( const PaUtilHostApiRepresentation
|
|||
return (const PaAlsaDeviceInfo *)hostApi->deviceInfos[device];
|
||||
}
|
||||
|
||||
static void AlsaErrorHandler(const char *file, int line, const char *function, int err, const char *fmt, ...)
|
||||
/** Uncommented because AlsaErrorHandler is unused for anything good yet. If AlsaErrorHandler is
|
||||
to be used, do not forget to register this callback in PaAlsa_Initialize, and unregister in Terminate.
|
||||
*/
|
||||
/*static void AlsaErrorHandler(const char *file, int line, const char *function, int err, const char *fmt, ...)
|
||||
{
|
||||
}
|
||||
}*/
|
||||
|
||||
PaError PaAlsa_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex hostApiIndex )
|
||||
{
|
||||
|
|
@ -262,7 +265,10 @@ PaError PaAlsa_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex
|
|||
(*hostApi)->OpenStream = OpenStream;
|
||||
(*hostApi)->IsFormatSupported = IsFormatSupported;
|
||||
|
||||
ENSURE_( snd_lib_error_set_handler(AlsaErrorHandler), paUnanticipatedHostError );
|
||||
/** If AlsaErrorHandler is to be used, do not forget to unregister callback pointer in
|
||||
Terminate function.
|
||||
*/
|
||||
/*ENSURE_( snd_lib_error_set_handler(AlsaErrorHandler), paUnanticipatedHostError );*/
|
||||
|
||||
PA_ENSURE( BuildDeviceList( alsaHostApi ) );
|
||||
|
||||
|
|
@ -308,6 +314,10 @@ static void Terminate( struct PaUtilHostApiRepresentation *hostApi )
|
|||
PaAlsaHostApiRepresentation *alsaHostApi = (PaAlsaHostApiRepresentation*)hostApi;
|
||||
|
||||
assert( hostApi );
|
||||
|
||||
/** See AlsaErrorHandler and PaAlsa_Initialize for details.
|
||||
*/
|
||||
/*snd_lib_error_set_handler(NULL);*/
|
||||
|
||||
if( alsaHostApi->allocations )
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue