Skip to content
New issue

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

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

Already on GitHub? # to your account

Overflow in _SDL_turnOnPCSpeaker #4

Open
64kramsystem opened this issue Aug 14, 2022 · 0 comments
Open

Overflow in _SDL_turnOnPCSpeaker #4

64kramsystem opened this issue Aug 14, 2022 · 0 comments

Comments

@64kramsystem
Copy link

64kramsystem commented Aug 14, 2022

The _SDL_turnOnPCSpeaker function performs this operation:

	pcPhaseLength = (pcSample*AudioSpec.freq)/(2*PC_BASE_TIMER);

now, pcSample is a 16 bit unsigned, and AudioSpec.freq a 32 bit signed; their product yields a 32 bit signed.

Since pcSample does reach a value of 65535, and AudioSpec.freq can be 48000, the result will overflow the 32 bit signed capacity.

I guess that one of the two should be casted to a 32 bit unsigned, which, conveniently, is also the pcPhaseLength size.

Snippet here.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant