mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
frontends/va: Fix parsing leb128 when using more than 4 bytes
Bit shift would go over 32 bits. Also add assert for maximum
value as allowed by spec.
Fixes coverity issue 1469252 Bad bit shift operation
Fixes: 5edbecb856 ("frontends/va: adding va av1 encoding functions")
Acked-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31622>
This commit is contained in:
parent
91222671f1
commit
2cb3c2e8d5
1 changed files with 3 additions and 2 deletions
|
|
@ -88,17 +88,18 @@ static unsigned av1_uvlc(struct vl_vlc *vlc)
|
|||
|
||||
static unsigned av1_uleb128(struct vl_vlc *vlc)
|
||||
{
|
||||
unsigned value = 0;
|
||||
uint64_t value = 0;
|
||||
unsigned leb128Bytes = 0;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < 8; ++i) {
|
||||
leb128Bytes = av1_f(vlc, 8);
|
||||
value |= ((leb128Bytes & 0x7f) << (i * 7));
|
||||
value |= ((uint64_t)(leb128Bytes & 0x7f) << (i * 7));
|
||||
if (!(leb128Bytes & 0x80))
|
||||
break;
|
||||
}
|
||||
|
||||
assert(value <= UINT32_MAX);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue