Skip to content

Accumulate leb128 value using uint64_t as intermediate type

Ronald S. Bultje requested to merge rbultje/dav1d:fix341 into master

The shift-amount can be up to 56, and left-shifting 32-bit integers by values >=32 is undefined behaviour. Therefore, use 64-bit integers instead. Also slightly rewrite so we only call dav1d_get_bits() once for the combined more|bits value, and mask the relevant portions out instead of reading twice. Lastly, move the overflow check out of the loop (as suggested by @wtc)

Fixes #341.

Edited by Ronald S. Bultje

Merge request reports