mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-08 06:09:50 +00:00
avcodec/rangecoder: Do not increase the pointer beyond the buffer
Fixes: undefined behavior Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
f4544163b2
commit
c359c51947
2 changed files with 7 additions and 2 deletions
|
|
@ -42,6 +42,8 @@ typedef struct RangeCoder {
|
|||
uint8_t *bytestream_start;
|
||||
uint8_t *bytestream;
|
||||
uint8_t *bytestream_end;
|
||||
int overread;
|
||||
#define MAX_OVERREAD 2
|
||||
} RangeCoder;
|
||||
|
||||
void ff_init_range_encoder(RangeCoder *c, uint8_t *buf, int buf_size);
|
||||
|
|
@ -106,9 +108,11 @@ static inline void refill(RangeCoder *c)
|
|||
if (c->range < 0x100) {
|
||||
c->range <<= 8;
|
||||
c->low <<= 8;
|
||||
if (c->bytestream < c->bytestream_end)
|
||||
if (c->bytestream < c->bytestream_end) {
|
||||
c->low += c->bytestream[0];
|
||||
c->bytestream++;
|
||||
c->bytestream++;
|
||||
} else
|
||||
c->overread ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue