mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Do not pass null to qobject_cast()
qobject_cast() implementations in Qt4 and Qt5 until version 5.4 unconditionally dereference the argument to access a static member. This is undefined behavior. When Goldendict is compiled with GCC's -fsanitize=undefined option in Release mode and launched with <useInternalPlayer>1</useInternalPlayer> in config, the application crashes right away with the following message: runtime error: member call on null pointer of type 'struct AudioPlayer'
This commit is contained in:
parent
fb71eb4ce1
commit
19ab09b754
|
@ -60,14 +60,14 @@ void AudioPlayerFactory::reset()
|
|||
|
||||
if( !internalPlayerBackend.isQtmultimedia() )
|
||||
{
|
||||
if( qobject_cast< Ffmpeg::AudioPlayer * >( playerPtr.data() ) == 0 )
|
||||
if( !playerPtr || !qobject_cast< Ffmpeg::AudioPlayer * >( playerPtr.data() ) )
|
||||
playerPtr.reset( new Ffmpeg::AudioPlayer );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MAKE_QTMULTIMEDIA_PLAYER
|
||||
if( qobject_cast< MultimediaAudioPlayer * >( playerPtr.data() ) == 0 )
|
||||
if( !playerPtr || !qobject_cast< MultimediaAudioPlayer * >( playerPtr.data() ) )
|
||||
playerPtr.reset( new MultimediaAudioPlayer );
|
||||
return;
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue