vp8 boolreader: ignore invalid input
authorJohann <johannkoenig@google.com>
Tue, 3 Dec 2019 23:29:35 +0000 (15:29 -0800)
committerJohann <johannkoenig@google.com>
Wed, 4 Dec 2019 22:01:28 +0000 (14:01 -0800)
Do basic initialization even when the result will not be used.

BUG=chromium:1026961

Change-Id: Iaa480534b49efe1ecc66484b316f8d654e8a1245

vp8/decoder/dboolhuff.c

index 9cf74bf..4cfaef0 100644 (file)
 int vp8dx_start_decode(BOOL_DECODER *br, const unsigned char *source,
                        unsigned int source_sz, vpx_decrypt_cb decrypt_cb,
                        void *decrypt_state) {
-  br->user_buffer_end = source + source_sz;
+  // To simplify calling code this fuction can be called with |source| == null
+  // and |source_sz| == 0. This and vp8dx_bool_decoder_fill() are essentially
+  // no-ops in this case.
+  // Work around a ubsan warning with a ternary to avoid adding 0 to null.
+  br->user_buffer_end = source ? source + source_sz : source;
   br->user_buffer = source;
   br->value = 0;
   br->count = -8;