Skip to content

Commit

Permalink
(fix) make read_tag skip extra padding bytes
Browse files Browse the repository at this point in the history
Some WAVE files are not just padded with \0 bytes (null terminators) but
arbitrary bytes. This causes the bug outlined in dancasimiro#101 & dancasimiro#102. Instead of
looking for consecutive \0 bytes read size from CHUNK and ignore
remainder of unused data.

See dancasimiro#101, dancasimiro#102
  • Loading branch information
CMGeldenhuys committed Jun 21, 2021
1 parent 99f366a commit bae71cf
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/WAVChunk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,14 @@ function read_tag(tags::Dict{Symbol, String}, t::Vector{UInt8})
end

i = 9
# Find first null terminator
while t[i] != 0
i += 1
end
tags[tag_id] = String(t[9:(i-1)])

# Skip null terminator/s, repeat in case multiple are present
while t[i] == 0 && i < length(t)
i += 1
end
# Return remainder of t
return t[i:end]
# Return remainder of t, skipping all data past first null terminator
return t[(9+size):end]
end

"""
Expand Down

0 comments on commit bae71cf

Please sign in to comment.