Merge pull request #4694 from akallabeth/mic_crash_fix

Fixed #4693: Fix integer underflow in encoder loop.
This commit is contained in:
David Fort 2018-06-04 11:29:01 +02:00 committed by GitHub
commit dad6b7a534
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -839,6 +839,7 @@ static BOOL freerdp_dsp_encode_ms_adpcm(FREERDP_DSP_CONTEXT* context, const BYTE
BYTE* dst;
INT32 sample;
UINT32 out_size;
const size_t step = 8 + (context->format.nChannels > 1) ? 4 : 0;
out_size = size / 2;
if (!Stream_EnsureRemainingCapacity(out, out_size))
@ -852,7 +853,7 @@ static BOOL freerdp_dsp_encode_ms_adpcm(FREERDP_DSP_CONTEXT* context, const BYTE
if (context->adpcm.ms.delta[1] < 16)
context->adpcm.ms.delta[1] = 16;
while (size > 0)
while (size >= step)
{
if ((dst - Stream_Buffer(out)) % context->format.nBlockAlign == 0)
{