Do basic initialization even when the result will not be used. BUG=chromium:1026961
Unified · Split
| @@ -15,7 +15,11 @@ · 14 unmodified lines | ||
| 15 | 15 | int vp8dx_start_decode(BOOL_DECODER *br, const unsigned char *source, |
| 16 | 16 | unsigned int source_sz, vpx_decrypt_cb decrypt_cb, |
| 17 | 17 | void *decrypt_state) { |
| 18 | − br->user_buffer_end = source + source_sz; | |
| 18 | + // To simplify calling code this fuction can be called with |source| == null | |
| 19 | + // and |source_sz| == 0. This and vp8dx_bool_decoder_fill() are essentially | |
| 20 | + // no-ops in this case. | |
| 21 | + // Work around a ubsan warning with a ternary to avoid adding 0 to null. | |
| 22 | + br->user_buffer_end = source ? source + source_sz : source; | |
| 19 | 23 | br->user_buffer = source; |
| 20 | 24 | br->value = 0; |
| 21 | 25 | br->count = -8; |