Merge "Add fbounds-safety annotations for VP8LBitReader." into main

This commit is contained in:
James Zern
2025-08-14 12:48:30 -07:00
committed by Gerrit Code Review
2 changed files with 11 additions and 9 deletions

View File

@@ -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);

View File

@@ -147,7 +147,7 @@ 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
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
@@ -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