From 53785a920622f35cb27290e0bc1a3f95b1cc2cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Wed, 28 Jun 2023 16:41:07 +0200 Subject: [PATCH] LibAudio: Handle bitstream errors in MP3 Huffman decode --- Userland/Libraries/LibAudio/MP3HuffmanTables.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibAudio/MP3HuffmanTables.h b/Userland/Libraries/LibAudio/MP3HuffmanTables.h index ee4bee58d5..45ed9ed8d9 100644 --- a/Userland/Libraries/LibAudio/MP3HuffmanTables.h +++ b/Userland/Libraries/LibAudio/MP3HuffmanTables.h @@ -112,9 +112,12 @@ HuffmanDecodeResult huffman_decode(BigEndianInputBitStream& bitstream, Readon size_t bits_read = 0; while (!node->is_leaf() && max_bits_to_read-- > 0) { - bool const direction = bitstream.read_bit().release_value_but_fixme_should_propagate_errors(); + auto const maybe_direction = bitstream.read_bit(); + if (maybe_direction.is_error()) + return { bits_read, {} }; + ++bits_read; - if (direction) { + if (maybe_direction.value()) { if (node->left == -1) return {}; node = &tree[node->left];