Skip to content

multiply_frac wrong overflow#55

Open
mdionisio wants to merge 2 commits intoxiph:masterfrom
mdionisio:master
Open

multiply_frac wrong overflow#55
mdionisio wants to merge 2 commits intoxiph:masterfrom
mdionisio:master

Conversation

@mdionisio
Copy link
Copy Markdown

I'm doing an asrc. I have problem because multiply_frac wrongly go in overflow.

My case is
in rate: 48000
out rate: 48000
num_rate: 500733
den_rate: 500000
num/den = 1.001466

and for example my samp_frac_num is 173475.

then I set
num_rate: 199999
den_rate: 1000000
num/den = 0.199999

this is a big change in ratio, but is done only to test.

When I do this change, I get overflow in multiply_frac function.

remain = 173475 > UINT32_MAX / 1000000 and this go in overflow.

but if I do all the operation with 64bit is ok
remain * num / den + major * num = 173475 * 199999 / 1000000 + 0 * 199999 = 34694 and this is correct.

the 2nd problem is that if multiply_frac fails wile I'm calling speex_resampler_set_rate_frac
the internal variable is left wrangly updated, and this create more problems later with possible access to invalid memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant