Commit 4dba0934 authored by Tristan Matthews's avatar Tristan Matthews

resampler: assert is sufficient for internal sanity check

parent 335a9a16
......@@ -591,14 +591,14 @@ static int resampler_basic_zero(SpeexResamplerState *st, spx_uint32_t channel_in
static int _muldiv(spx_uint32_t *result, spx_uint32_t value, spx_uint32_t mul, spx_uint32_t div)
{
speex_assert(result);
spx_uint32_t major = value / div;
spx_uint32_t remainder = value % div;
/* TODO: Could use 64 bits operation to check for overflow. But only guaranteed in C99+ */
if (remainder > UINT32_MAX / mul || major > UINT32_MAX / mul
|| major * mul > UINT32_MAX - remainder * mul / div)
return RESAMPLER_ERR_OVERFLOW;
if (result)
*result = remainder * mul / div + major * mul;
*result = remainder * mul / div + major * mul;
return RESAMPLER_ERR_SUCCESS;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment