Skip to content

Commit

Permalink
Avoid nullptr with zero offset
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 516808122
  • Loading branch information
eustas committed Jul 4, 2023
1 parent cb1ced3 commit f29c44e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions c/dec/bit_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static BROTLI_INLINE void BrotliBitReaderSaveState(
static BROTLI_INLINE void BrotliBitReaderSetInput(
BrotliBitReader* const br, const uint8_t* next_in, size_t avail_in) {
br->next_in = next_in;
br->last_in = next_in + avail_in;
br->last_in = (avail_in == 0) ? next_in : (next_in + avail_in);
if (avail_in + 1 > BROTLI_FAST_INPUT_SLACK) {
br->guard_in = next_in + (avail_in + 1 - BROTLI_FAST_INPUT_SLACK);
} else {
Expand Down Expand Up @@ -251,7 +251,8 @@ static BROTLI_INLINE void BrotliDropBits(
static BROTLI_INLINE void BrotliBitReaderUnload(BrotliBitReader* br) {
brotli_reg_t unused_bytes = BrotliGetAvailableBits(br) >> 3;
brotli_reg_t unused_bits = unused_bytes << 3;
br->next_in -= unused_bytes;
br->next_in =
(unused_bytes == 0) ? br->next_in : (br->next_in - unused_bytes);
if (unused_bits == sizeof(br->val_) << 3) {
br->val_ = 0;
} else {
Expand Down

0 comments on commit f29c44e

Please sign in to comment.