Skip to content

Commit

Permalink
Check for invalid data in audio switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
clsid2 committed Nov 24, 2022
1 parent 9f26d48 commit eab8d92
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
int bps = wfe->wBitsPerSample >> 3;

int len = pIn->GetActualDataLength() / (bps * wfe->nChannels);
if (len < 0 || wfe->nSamplesPerSec == 0) {
return S_FALSE;
}
int lenout = (UINT64)len * wfeout->nSamplesPerSec / wfe->nSamplesPerSec;

REFERENCE_TIME rtStart, rtStop;
Expand Down Expand Up @@ -269,7 +272,7 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
return hr;
}

if (!pDataIn || !pDataOut || len < 0 || lenout < 0) {
if (!pDataIn || !pDataOut) {
return S_FALSE;
}
// len = 0 doesn't mean it's failed, return S_OK otherwise might screw the sound
Expand Down

0 comments on commit eab8d92

Please sign in to comment.