Commit 32908aae authored by James Almer's avatar James Almer

annexb: don't use a int64_t intermediary for leb128

There are other checks present already that ensure the coded value remains within
the allowed range.
parent a0fb010f
Pipeline #3420 passed with stages
in 4 minutes and 44 seconds
......@@ -44,21 +44,18 @@ typedef struct DemuxerPriv {
static int leb128(AnnexbInputContext *const c, size_t *const len) {
unsigned more, i = 0;
int64_t sz = 0;
uint8_t byte;
*len = 0;
do {
if (fread(&byte, 1, 1, c->f) < 1)
return -1;
more = byte & 0x80;
unsigned bits = byte & 0x7f;
if (i <= 3 || (i == 4 && bits < (1 << 4)))
sz |= (int64_t)bits << (i * 7);
*len |= bits << (i * 7);
else if (bits) return -1;
if (++i == 8 && more) return -1;
} while (more);
if (sz > 0xFFFFFFFFU)
return -1;
*len = sz;
return i;
}
......
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