Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimePos::quantize() crashes when called with quantization 1/192 #5899

Closed
IanCaio opened this issue Jan 31, 2021 · 2 comments
Closed

TimePos::quantize() crashes when called with quantization 1/192 #5899

IanCaio opened this issue Jan 31, 2021 · 2 comments
Labels

Comments

@IanCaio
Copy link
Contributor

IanCaio commented Jan 31, 2021

Bug Summary

If the method TimePos::quantize() is called with quantization 1/192, it causes an arithmetic exception because the variable interval ends up equal to 1 and the expression int snapUp = offset / (interval / 2); causes a division by 0.

Steps to reproduce

This bug was found out while code from a PR was being tested. It might not affect any existing functionality of LMMS, since I believe TimePos::quantize() is only being called when quantization is bigger than 1/192.

Expected behavior

TimePos::quantize() returning the same TimePos that it was given.

Actual behavior

Arithmetic Exception crash.

Thanks @rghvdberg for finding the bug!

@IanCaio IanCaio added the bug label Jan 31, 2021
@Spekular
Copy link
Member

snapUp = offset / (interval / 2)

Wasn't this fixed in some PR to be snapUp = 2 * offset / interval?

@IanCaio
Copy link
Contributor Author

IanCaio commented Jan 31, 2021

🤦‍♂️

I was looking at the file from the branch I fetched from the PR, and just now I noticed it's 19 commits behind master. You're right, this is fixed by #5847 . Double facepalm because I was the one that submitted it 🤣

@IanCaio IanCaio closed this as completed Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants