avfilter/avf_showwaves: Check max_samples
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 3 Sep 2015 12:52:18 +0000 (14:52 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 3 Sep 2015 17:27:20 +0000 (19:27 +0200)
Fixes potential division by zero
Fixes: CID1292295

Reviewed-by: Ganesh Ajjanagadde <gajjanag@mit.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavfilter/avf_showwaves.c

index 57a6b2e..a19acf5 100644 (file)
@@ -203,6 +203,11 @@ static int push_single_pic(AVFilterLink *outlink)
     int col = 0;
     int64_t *sum = showwaves->sum;
 
+    if (max_samples == 0) {
+        av_log(ctx, AV_LOG_ERROR, "Too few samples\n");
+        return AVERROR(EINVAL);
+    }
+
     av_log(ctx, AV_LOG_DEBUG, "Create frame averaging %"PRId64" samples per column\n", max_samples);
 
     memset(sum, 0, nb_channels);