aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/h264_parse.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-06-10 00:13:07 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-06-10 00:48:23 +0200
commit09096fb68713089a8f97c8fa24e9d7f3bb9231d5 (patch)
tree0f69522bb118bea51806a950b36e3551778df981 /libavcodec/h264_parse.c
parente1b0044c234775bf99ab1a5c794240a9a692ad8d (diff)
downloadffmpeg-09096fb68713089a8f97c8fa24e9d7f3bb9231d5.tar.gz
avcodec/h264_parse: Check picture structure when initializing weight table
Fixes: runtime error: index 49 out of bounds for type 'int [48][2][2]' Fixes: 2159/clusterfuzz-testcase-minimized-5267945972301824 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/h264_parse.c')
-rw-r--r--libavcodec/h264_parse.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index ea202e759c..3d20075f6a 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -26,7 +26,8 @@
int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
const int *ref_count, int slice_type_nos,
- H264PredWeightTable *pwt, void *logctx)
+ H264PredWeightTable *pwt,
+ int picture_structure, void *logctx)
{
int list, i, j;
int luma_def, chroma_def;
@@ -98,11 +99,13 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
}
// for MBAFF
- pwt->luma_weight[16 + 2 * i][list][0] = pwt->luma_weight[16 + 2 * i + 1][list][0] = pwt->luma_weight[i][list][0];
- pwt->luma_weight[16 + 2 * i][list][1] = pwt->luma_weight[16 + 2 * i + 1][list][1] = pwt->luma_weight[i][list][1];
- for (j = 0; j < 2; j++) {
- pwt->chroma_weight[16 + 2 * i][list][j][0] = pwt->chroma_weight[16 + 2 * i + 1][list][j][0] = pwt->chroma_weight[i][list][j][0];
- pwt->chroma_weight[16 + 2 * i][list][j][1] = pwt->chroma_weight[16 + 2 * i + 1][list][j][1] = pwt->chroma_weight[i][list][j][1];
+ if (picture_structure == PICT_FRAME) {
+ pwt->luma_weight[16 + 2 * i][list][0] = pwt->luma_weight[16 + 2 * i + 1][list][0] = pwt->luma_weight[i][list][0];
+ pwt->luma_weight[16 + 2 * i][list][1] = pwt->luma_weight[16 + 2 * i + 1][list][1] = pwt->luma_weight[i][list][1];
+ for (j = 0; j < 2; j++) {
+ pwt->chroma_weight[16 + 2 * i][list][j][0] = pwt->chroma_weight[16 + 2 * i + 1][list][j][0] = pwt->chroma_weight[i][list][j][0];
+ pwt->chroma_weight[16 + 2 * i][list][j][1] = pwt->chroma_weight[16 + 2 * i + 1][list][j][1] = pwt->chroma_weight[i][list][j][1];
+ }
}
}
if (slice_type_nos != AV_PICTURE_TYPE_B)