diff options
author | Karol Kosek <krkk@krkk.ct8.pl> | 2021-07-21 15:58:57 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-21 22:12:44 +0200 |
commit | 3c62b661f46b4764d3835153091d48b54736b941 (patch) | |
tree | 351c1cfbbdbbe4518543d87e179db34695aff12d /Userland | |
parent | 9c71e43c3f8754a5fc2a5410b1c2bf45154d4689 (diff) | |
download | serenity-3c62b661f46b4764d3835153091d48b54736b941.zip |
LibAudio: Fix UTF-8 decoding logic in FLAC decoding :^)
The problem here was that the multi-byte UTF-8 encoded characters
were taking one byte too much, misaligning the data completely
and eventually crashing the program on the 128th frame.
This change reduces the for loop by one, as it has been already
calculated from the start_byte variable.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibAudio/FlacLoader.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibAudio/FlacLoader.cpp b/Userland/Libraries/LibAudio/FlacLoader.cpp index 86e12e380c..3289dcc846 100644 --- a/Userland/Libraries/LibAudio/FlacLoader.cpp +++ b/Userland/Libraries/LibAudio/FlacLoader.cpp @@ -802,7 +802,7 @@ u64 read_utf8_char(InputStream& input) u8 bits_from_start_byte = 8 - (length + 1); u8 start_byte_bitmask = AK::exp2(bits_from_start_byte) - 1; character = start_byte_bitmask & start_byte; - for (u8 i = length; i > 0; --i) { + for (u8 i = length - 1; i > 0; --i) { input.read(single_byte_buffer); u8 current_byte = single_byte_buffer[0]; character = (character << 6) | (current_byte & 0b00111111); |