Skip to content

fixed: AudioGeneratorMP3 reads uninitialized memory on first iteration#522

Closed
RomanLut wants to merge 3 commits intoearlephilhower:masterfrom
RomanLut:mp3_read_garbage
Closed

fixed: AudioGeneratorMP3 reads uninitialized memory on first iteration#522
RomanLut wants to merge 3 commits intoearlephilhower:masterfrom
RomanLut:mp3_read_garbage

Conversation

@RomanLut
Copy link
Contributor

@RomanLut RomanLut commented May 7, 2022

On the first iteration, AudioGeneratorMP3 is reading synth->pcm.samples[0][samplePtr] array which is not initialized.
May cause Pop sound due to garbage in array.

@RomanLut RomanLut changed the title fixed: AudioGeneratorMP3 read uninitialized memory on first iteration fixed: AudioGeneratorMP3 reads uninitialized memory on first iteration May 8, 2022
@earlephilhower
Copy link
Owner

Thanks for the contribution but going through the logic, it doesn't seem to be right. GetOneSample calls the mac-get-onens if there's nothing left buffered. That MAD call will fill in a series of samples and return an error or not. We return false here on error, indicating no data. If the onens call is successful we know that synth->pcm.samples[0][samplePtr (aka 0)];` is valid.

I also run the MP3 decode through valgrind as part of host tests and it catches things like reads to unwritten memory. It's not reported anything 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

Successfully merging this pull request may close these issues.

2 participants