diff --git a/libavcodec/utils.c b/libavcodec/utils.c index cc04b73471..1b1feca38c 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -962,6 +962,10 @@ FF_ENABLE_DEPRECATION_WARNINGS ret = AVERROR(EINVAL); goto free_and_end; } + if (avctx->bits_per_coded_sample < 0) { + ret = AVERROR(EINVAL); + goto free_and_end; + } if (avctx->sub_charenc) { if (avctx->codec_type != AVMEDIA_TYPE_SUBTITLE) { av_log(avctx, AV_LOG_ERROR, "Character encoding is only "