From 088eca28164c8cd3b72b0c3d3f9e3fe5ee5cb28f Mon Sep 17 00:00:00 2001 From: Vittorio Giovara Date: Wed, 15 Oct 2014 17:33:00 +0100 Subject: [PATCH] avresample: prevent theoretical division by zero CC: libav-stable@libav.org Bug-Id: CID 1231986 --- libavresample/utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavresample/utils.c b/libavresample/utils.c index 5d095c054b..8ba8a0975b 100644 --- a/libavresample/utils.c +++ b/libavresample/utils.c @@ -585,9 +585,12 @@ static inline int convert_frame(AVAudioResampleContext *avr, static inline int available_samples(AVFrame *out) { + int samples; int bytes_per_sample = av_get_bytes_per_sample(out->format); - int samples = out->linesize[0] / bytes_per_sample; + if (!bytes_per_sample) + return AVERROR(EINVAL); + samples = out->linesize[0] / bytes_per_sample; if (av_sample_fmt_is_planar(out->format)) { return samples; } else {