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

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

Last try. Adds new check in another method that does the same work

  • 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 |   21 +++++++++++----------
     1 files changed, 11 insertions(+), 10 deletions(-)
    
    diff --git a/libs/libmyth/audiooutputbase.cpp b/libs/libmyth/audiooutputbase.cpp
    index 9bcbe97..d7c685c 100644
    a b void AudioOutputBase::SetStretchFactorLocked(float laudio_stretchfactor) 
    147147                                QString("Failed to Create Encoder"));
    148148                    }
    149149                }
    150             }
    151             if (encoder)
    152             {
    153                 pSoundStretch->setSampleRate(audio_codec->sample_rate);
    154                 pSoundStretch->setChannels(audio_codec->channels);
     150                if (encoder)
     151                {
     152                    pSoundStretch->setSampleRate(audio_codec->sample_rate);
     153                    pSoundStretch->setChannels(audio_codec->channels);
     154                }
    155155            }
    156156            else
    157157            {
    void AudioOutputBase::Reconfigure(int laudio_bits, int laudio_channels, 
    396396                        VERBOSE(VB_AUDIO, LOC + "Failed to Create Encoder");
    397397                    }
    398398                }
    399             }
    400             if (encoder)
    401             {
    402                 pSoundStretch->setSampleRate(audio_codec->sample_rate);
    403                 pSoundStretch->setChannels(audio_codec->channels);
     399
     400                if (encoder)
     401                {
     402                    pSoundStretch->setSampleRate(audio_codec->sample_rate);
     403                    pSoundStretch->setChannels(audio_codec->channels);
     404                }
    404405            }
    405406            else
    406407            {