lavfi/showspectrum: fix crash in case of negative linesize
authorPaul B Mahol <onemda@gmail.com>
Mon, 29 Apr 2013 13:31:04 +0000 (13:31 +0000)
committerPaul B Mahol <onemda@gmail.com>
Mon, 29 Apr 2013 19:27:15 +0000 (19:27 +0000)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
libavfilter/avf_showspectrum.c

index 058f22c..7cd75df 100644 (file)
@@ -211,9 +211,11 @@ static int config_output(AVFilterLink *outlink)
         if (!outpicref)
             return AVERROR(ENOMEM);
         outlink->sample_aspect_ratio = (AVRational){1,1};
-        memset(outpicref->data[0],   0, outlink->h * outpicref->linesize[0]);
-        memset(outpicref->data[1], 128, outlink->h * outpicref->linesize[1]);
-        memset(outpicref->data[2], 128, outlink->h * outpicref->linesize[2]);
+        for (i = 0; i < outlink->h; i++) {
+            memset(outpicref->data[0] + i * outpicref->linesize[0],   0, outlink->w);
+            memset(outpicref->data[1] + i * outpicref->linesize[1], 128, outlink->w);
+            memset(outpicref->data[2] + i * outpicref->linesize[2], 128, outlink->w);
+        }
     }
 
     if (showspectrum->xpos >= outlink->w)