avresample: prevent theoretical division by zero
authorVittorio Giovara <vittorio.giovara@gmail.com>
Wed, 15 Oct 2014 16:33:00 +0000 (17:33 +0100)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Sat, 18 Oct 2014 15:15:10 +0000 (16:15 +0100)
CC: libav-stable@libav.org
Bug-Id: CID 1231986

libavresample/utils.c

index 5d095c0..8ba8a09 100644 (file)
@@ -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 {