From 7266cd8b6c3a1f515d1bdb4c91e49e6994f72951 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 28 Aug 2020 06:42:14 -0700 Subject: Don't dereference a null convolution filter --- alc/effects/convolution.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'alc') diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index 8acf6010..2700cb6e 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -138,7 +138,7 @@ struct ConvolutionState final : public EffectState { void NormalMix(const al::span samplesOut, const size_t samplesToDo); void UpsampleMix(const al::span samplesOut, const size_t samplesToDo); - void (ConvolutionState::*Mix)(const al::span,const size_t) + void (ConvolutionState::*mMix)(const al::span,const size_t) {&ConvolutionState::NormalMix}; void deviceUpdate(const ALCdevice *device) override; @@ -273,8 +273,10 @@ void ConvolutionState::update(const ALCcontext *context, const ALeffectslot *slo const EffectProps* /*props*/, const EffectTarget target) { mFilter = static_cast(slot->Params.mEffectBuffer); - mNumChannels = ChannelsFromFmt(mFilter->mChannels, mFilter->mAmbiOrder); - Mix = &ConvolutionState::NormalMix; + if(!mFilter) return; + + mNumChannels = mFilter ? ChannelsFromFmt(mFilter->mChannels, mFilter->mAmbiOrder) : 0u; + mMix = &ConvolutionState::NormalMix; /* The iFFT'd response is scaled up by the number of bins, so apply the * inverse to the output mixing gain. @@ -286,7 +288,7 @@ void ConvolutionState::update(const ALCcontext *context, const ALeffectslot *slo ALCdevice *device{context->mDevice.get()}; if(device->mAmbiOrder > mFilter->mAmbiOrder) { - Mix = &ConvolutionState::UpsampleMix; + mMix = &ConvolutionState::UpsampleMix; const auto scales = BFormatDec::GetHFOrderScales(mFilter->mAmbiOrder, device->mAmbiOrder); mOutChans[0].mHfScale = scales[0]; @@ -419,7 +421,7 @@ void ConvolutionState::process(const size_t samplesToDo, mFilter->mCurrentSegment = curseg; /* Finally, mix to the output. */ - (this->*Mix)(samplesOut, samplesToDo); + (this->*mMix)(samplesOut, samplesToDo); } -- cgit v1.2.3