diff --git a/src/utils/bit_reader_utils.c b/src/utils/bit_reader_utils.c index 0720213a..3a2f1d2e 100644 --- a/src/utils/bit_reader_utils.c +++ b/src/utils/bit_reader_utils.c @@ -139,6 +139,7 @@ void VP8LInitBitReader(VP8LBitReader* const br, assert(start != NULL); assert(length < 0xfffffff8u); // can't happen with a RIFF chunk. + br->buf = start; br->len = length; br->val = 0; br->bit_pos = 0; @@ -152,10 +153,10 @@ void VP8LInitBitReader(VP8LBitReader* const br, } br->val = value; br->pos = length; - br->buf = start; } -void VP8LBitReaderSetBuffer(VP8LBitReader* const br, const uint8_t* const buf, +void VP8LBitReaderSetBuffer(VP8LBitReader* const br, + const uint8_t* const WEBP_COUNTED_BY(len) buf, size_t len) { assert(br != NULL); assert(buf != NULL); diff --git a/src/utils/bit_reader_utils.h b/src/utils/bit_reader_utils.h index cd3bd7e2..efb217a5 100644 --- a/src/utils/bit_reader_utils.h +++ b/src/utils/bit_reader_utils.h @@ -146,12 +146,12 @@ int32_t VP8GetSignedValue(VP8BitReader* const br, int num_bits, typedef uint64_t vp8l_val_t; // right now, this bit-reader can only use 64bit. typedef struct { - vp8l_val_t val; // pre-fetched bits - const uint8_t* buf; // input byte buffer - size_t len; // buffer length - size_t pos; // byte position in buf - int bit_pos; // current bit-reading position in val - int eos; // true if a bit was read past the end of buffer + vp8l_val_t val; // pre-fetched bits + const uint8_t* WEBP_COUNTED_BY(len) buf; // input byte buffer + size_t len; // buffer length + size_t pos; // byte position in buf + int bit_pos; // current bit-reading position in val + int eos; // true if a bit was read past the end of buffer } VP8LBitReader; void VP8LInitBitReader(VP8LBitReader* const br, @@ -160,7 +160,8 @@ void VP8LInitBitReader(VP8LBitReader* const br, // Sets a new data buffer. void VP8LBitReaderSetBuffer(VP8LBitReader* const br, - const uint8_t* const buffer, size_t length); + const uint8_t* const WEBP_COUNTED_BY(length) buffer, + size_t length); // Reads the specified number of bits from read buffer. // Flags an error in case end_of_stream or n_bits is more than the allowed limit