diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 14b945756b..84b5710ab4 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -922,6 +922,11 @@ static int h264_slice_header_init(H264Context *h) const SPS *sps = h->ps.sps; int i, ret; + if (!sps) { + ret = AVERROR_INVALIDDATA; + goto fail; + } + ff_set_sar(h->avctx, sps->sar); av_pix_fmt_get_chroma_sub_sample(h->avctx->pix_fmt, &h->chroma_x_shift, &h->chroma_y_shift);