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

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

This is the same check for null, but it leverages the conditional right before

  • 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..aa23e8d 100644
    a b 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);
    404             }
    405             else
    406             {
    407                 pSoundStretch->setSampleRate(audio_samplerate);
    408                 pSoundStretch->setChannels(audio_channels);
     399
     400                if (encoder)
     401                {
     402                    pSoundStretch->setSampleRate(audio_codec->sample_rate);
     403                    pSoundStretch->setChannels(audio_codec->channels);
     404                }
     405                else
     406                {
     407                    pSoundStretch->setSampleRate(audio_samplerate);
     408                    pSoundStretch->setChannels(audio_channels);
     409                }
    409410            }
    410411        }
    411412    }