diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-06-24 14:46:17 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-06-24 22:17:15 +0200 |
commit | 933aa91e31d5cbf9dbc0cf416a988e6011bc4a40 (patch) | |
tree | 6953e13b3c8779f7e7c7859b28e6e00f48860959 /libavcodec/hevcdec.c | |
parent | c1b43e8452e778edea757e912d17780df1ebd92d (diff) | |
download | ffmpeg-933aa91e31d5cbf9dbc0cf416a988e6011bc4a40.tar.gz |
avcodec/hevcdec: check ff_init_cabac_decoder() for failure
Fixes: runtime error: left shift of 1965559808 by 4 places cannot be represented in type 'int'
Fixes: 2333/clusterfuzz-testcase-minimized-5223935677300736
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/hevcdec.c')
-rw-r--r-- | libavcodec/hevcdec.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 0c478029c9..83130fc48f 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2337,6 +2337,7 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread) int x_ctb = 0; int y_ctb = 0; int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]; + int ret; if (!ctb_addr_ts && s->sh.dependent_slice_segment_flag) { av_log(s->avctx, AV_LOG_ERROR, "Impossible initial tile.\n"); @@ -2358,7 +2359,11 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread) y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size; hls_decode_neighbour(s, x_ctb, y_ctb, ctb_addr_ts); - ff_hevc_cabac_init(s, ctb_addr_ts); + ret = ff_hevc_cabac_init(s, ctb_addr_ts); + if (ret < 0) { + s->tab_slice_address[ctb_addr_rs] = -1; + return ret; + } hls_sao_param(s, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size); @@ -2417,7 +2422,9 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int if (ret < 0) return ret; - ff_init_cabac_decoder(&lc->cc, s->data + s->sh.offset[(ctb_row)-1], s->sh.size[ctb_row - 1]); + ret = ff_init_cabac_decoder(&lc->cc, s->data + s->sh.offset[(ctb_row)-1], s->sh.size[ctb_row - 1]); + if (ret < 0) + goto error; } while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) { @@ -2433,15 +2440,15 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int return 0; } - ff_hevc_cabac_init(s, ctb_addr_ts); + ret = ff_hevc_cabac_init(s, ctb_addr_ts); + if (ret < 0) + goto error; hls_sao_param(s, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size); more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->ps.sps->log2_ctb_size, 0); if (more_data < 0) { - s->tab_slice_address[ctb_addr_rs] = -1; - atomic_store(&s1->wpp_err, 1); - ff_thread_report_progress2(s->avctx, ctb_row ,thread, SHIFT_CTB_WPP); - return more_data; + ret = more_data; + goto error; } ctb_addr_ts++; @@ -2471,6 +2478,11 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int ff_thread_report_progress2(s->avctx, ctb_row ,thread, SHIFT_CTB_WPP); return 0; +error: + s->tab_slice_address[ctb_addr_rs] = -1; + atomic_store(&s1->wpp_err, 1); + ff_thread_report_progress2(s->avctx, ctb_row ,thread, SHIFT_CTB_WPP); + return ret; } static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) |