mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:57:35 +00:00
LibAudio: Handle bitstream errors in MP3 Huffman decode
This commit is contained in:
parent
2ba77489ee
commit
53785a9206
1 changed files with 5 additions and 2 deletions
|
@ -112,9 +112,12 @@ HuffmanDecodeResult<T> huffman_decode(BigEndianInputBitStream& bitstream, Readon
|
||||||
size_t bits_read = 0;
|
size_t bits_read = 0;
|
||||||
|
|
||||||
while (!node->is_leaf() && max_bits_to_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;
|
++bits_read;
|
||||||
if (direction) {
|
if (maybe_direction.value()) {
|
||||||
if (node->left == -1)
|
if (node->left == -1)
|
||||||
return {};
|
return {};
|
||||||
node = &tree[node->left];
|
node = &tree[node->left];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue