Commit a537c5ac authored by Janne Grunau's avatar Janne Grunau

get_bits: avoid infinite loops in get_vlc() at EOF

Fixes a fuzzing time out with timeout-e372a93d3be3f703bb7a49ce3d92c72d06f3b9cb.
parent 4ec4605b
......@@ -89,8 +89,9 @@ unsigned get_uniform(GetBits *const c, const unsigned n) {
unsigned get_vlc(GetBits *const c) {
int n_bits = 0;
while (!get_bits(c, 1)) n_bits++;
if (n_bits >= 32) return 0xFFFFFFFFU;
while (!get_bits(c, 1))
if (++n_bits == 32)
return 0xFFFFFFFFU;
return ((1 << n_bits) - 1) + get_bits(c, n_bits);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment