8000 Overflow in `_SDL_turnOnPCSpeaker` · Issue #4 · Blzut3/CatacombSDL · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Overflow in _SDL_turnOnPCSpeaker #4

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

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.

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

No branches or pull requests

1 participant
0