diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1e10325c1f..468790e9ae 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1644,6 +1644,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 "