From 654bfb040cf283b0acdd7be78d2d955131662319 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Thu, 30 Jan 2025 00:12:15 +0100 Subject: [PATCH] Avoid nullptr arithmetic in VP8BitReaderSetBuffer When start is nullptr, the IO is not used afterwards anyway, so there is not risk. Change-Id: I0a828aec85c6e228e95dfed4a40d348275a7c577 --- src/utils/bit_reader_utils.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/utils/bit_reader_utils.c b/src/utils/bit_reader_utils.c index 2707420f..5270b868 100644 --- a/src/utils/bit_reader_utils.c +++ b/src/utils/bit_reader_utils.c @@ -15,6 +15,8 @@ #include "src/webp/config.h" #endif +#include + #include "src/dsp/cpu.h" #include "src/utils/bit_reader_inl_utils.h" #include "src/utils/utils.h" @@ -25,11 +27,12 @@ void VP8BitReaderSetBuffer(VP8BitReader* const br, const uint8_t* const start, size_t size) { - br->buf_ = start; - br->buf_end_ = start + size; - br->buf_max_ = - (size >= sizeof(lbit_t)) ? start + size - sizeof(lbit_t) + 1 - : start; + if (start != NULL) { + br->buf_ = start; + br->buf_end_ = start + size; + br->buf_max_ = + (size >= sizeof(lbit_t)) ? start + size - sizeof(lbit_t) + 1 : start; + } } void VP8InitBitReader(VP8BitReader* const br,