Looking at the spec for METADATA_BLOCK_VORBIS_COMMENT, it appears there aren't any alignment requirements, so the uint32's may not be 4 byte aligned. This may need to be also be fixed in other metadata blocks.
This PR adds a function to read a little endian 32 bit integer from a potentially unaligned ptr and replaces the uint32 reading for METADATA_BLOCK_VORBIS_COMMENT with it. This fix should work on big and little endian.
Edit: Also added fix to drflac_next_vorbis_comment as I ran into the same issue there.
Edit2: Fixed DRFLAC_METADATA_BLOCK_TYPE_PICTURE
Using an emscripten debug build with
-s SAFE_HEAP=1
https://emscripten.org/docs/porting/Debugging.html#compiler-settings it got an alignment fault on https://github.com/mackron/dr_libs/blob/c5e53558165585ae624a7d6c7908e698609093c8/dr_flac.h#L6514 when callingdrflac_open_with_metadata
.Looking at the spec for
METADATA_BLOCK_VORBIS_COMMENT
, it appears there aren't any alignment requirements, so theuint32
's may not be 4 byte aligned. This may need to be also be fixed in other metadata blocks.This PR adds a function to read a little endian 32 bit integer from a potentially unaligned ptr and replaces the uint32 reading for
METADATA_BLOCK_VORBIS_COMMENT
with it. This fix should work on big and little endian.Edit: Also added fix to
drflac_next_vorbis_comment
as I ran into the same issue there. Edit2: FixedDRFLAC_METADATA_BLOCK_TYPE_PICTURE