Ticket #4746: libs_libmyth_audiooutputbase.cpp-fix-forgotten-null-check.patch

File libs_libmyth_audiooutputbase.cpp-fix-forgotten-null-check.patch, 1.3 KB (added by Erik Hovland <erik@…>, 13 years ago)

Adds check of audio_codec pointer before it is dereferenced

  • libs/libmyth/audiooutputbase.cpp

    In Reconfigure there is a point where the audio_codec pointer is dereferenced but
    
    From: Erik Hovland <erik@hovland.org>
    
    not checked for null. This can cause a segfault. This patch adds the check.
    ---
    
     libs/libmyth/audiooutputbase.cpp |   14 ++++++++++++--
     1 files changed, 12 insertions(+), 2 deletions(-)
    
    diff --git a/libs/libmyth/audiooutputbase.cpp b/libs/libmyth/audiooutputbase.cpp
    index 9bcbe97..1873e0d 100644
    a b void AudioOutputBase::Reconfigure(int laudio_bits, int laudio_channels, 
    399399            }
    400400            if (encoder)
    401401            {
    402                 pSoundStretch->setSampleRate(audio_codec->sample_rate);
    403                 pSoundStretch->setChannels(audio_codec->channels);
     402                if (audio_codec)
     403                {
     404                    pSoundStretch->setSampleRate(audio_codec->sample_rate);
     405                    pSoundStretch->setChannels(audio_codec->channels);
     406                }
     407                else
     408                {
     409                    VERBOSE(VB_AUDIO,
     410                            LOC + "Audio Codec not yet set. "
     411                            "SoundStretch sample rate and number of channels "
     412                            "are uninitialized");
     413                }
    404414            }
    405415            else
    406416            {