Skip to content

Conversation

@lakor64
Copy link

@lakor64 lakor64 commented Dec 25, 2021

The following code implements seeking for WAV, FLAC and MP3 on the . This also fixes looping on those three file types when enabled.

By looking on the offset code on OGG (with stb_vorbis_get_sample_offset), I am not sure if it's required on dr* libraries as it doesn't seem to jump to a different PCM, I guess stb_vorbis_get_sample_offsets gets the position that we seek?

@HailToDodongo
Copy link

@jarikomppa
This PR actually fixes a pretty serious memory corruption issue i was facing in my project.
I traced this bug down with valgrind, where this exact function (WavStreamInstance::seek) was always the root-cause of invalid memory writes.

Before, this code only checked for mCodec.mOgg != nullptr and then assumed that the codec is ogg-vorbis.
However mCodec is a union, so every type (including wave) will have mCodec.mOgg set.
This causes stb_vorbis_get_sample_offset (treating *mWav's value as *mOgg) to write to arbitrary memory, which in my case lead to a crash.
Writes where also wide-spread, since the struct contains channel- and sample-counts which potentially became pretty large numbers.

After applying this patch, all other related OOB writes also vanished.
#279 seems to be related to this, since i got the exact same behaviour of null-pointers in that array.
This stopped too after that change.

@tgalaj
Copy link

tgalaj commented Jun 28, 2025

Why not merged yet? Is project abandoned?

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.

3 participants