ref: 32908aae0f99eae453ed4e255978e3365abd123e
parent: a0fb010fd0bd8e465b8ac2d5234f3bd16a94b2ad
author: James Almer <jamrial@gmail.com>
date: Sat Dec 8 11:57:21 EST 2018
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.
--- a/tools/input/annexb.c
+++ b/tools/input/annexb.c
@@ -44,8 +44,8 @@
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;
@@ -52,13 +52,10 @@
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;
}