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

Mixer: Add assertions regarding num_samples versus buffer length #11011

Merged
merged 2 commits into from Sep 8, 2022

Conversation

Pokechu22
Copy link
Contributor

Compare #10664. I haven't been able to reproduce any buffer overflows (other than the audio dumping one from #10741), but hopefully these assertions will make them more obvious when they happen.

(I didn't add any assertions to Mixer::MixerFifo::PushSamples because that code should already be free of overflows due to the masking.)

static constexpr u32 MAX_SPEAKER_SAMPLES = 20 * 2;
std::array<short, MAX_SPEAKER_SAMPLES * 2> samples_stereo;

ASSERT_MSG(AUDIO, num_samples < MAX_SPEAKER_SAMPLES,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be num_samples <= MAX_SPEAKER_SAMPLES... Actually I think this applies to all of the asserts as well as the if a few lines down.

@AdmiralCurtiss
Copy link
Contributor

Seems good, let's see if anything or anyone triggers these.

@AdmiralCurtiss AdmiralCurtiss merged commit 200c9dd into dolphin-emu:master Sep 8, 2022
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants