Browse code

avfilter/avf_showspectrum: do not use uninitialized memory

Paul B Mahol authored on 2016/08/19 01:40:00
Showing 1 changed files
... ...
@@ -380,7 +380,7 @@ static int config_output(AVFilterLink *outlink)
380 380
         if (!s->color_buffer)
381 381
             return AVERROR(ENOMEM);
382 382
         for (i = 0; i < s->nb_display_channels; i++) {
383
-            s->color_buffer[i] = av_malloc_array(s->orientation == VERTICAL ? s->h * 3 : s->w * 3, sizeof(**s->color_buffer));
383
+            s->color_buffer[i] = av_calloc(s->orientation == VERTICAL ? s->h * 3 : s->w * 3, sizeof(**s->color_buffer));
384 384
             if (!s->color_buffer[i])
385 385
                 return AVERROR(ENOMEM);
386 386
         }
... ...
@@ -730,8 +730,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
730 730
     ctx->internal->execute(ctx, plot_channel, NULL, NULL, s->nb_display_channels);
731 731
 
732 732
     for (y = 0; y < z * 3; y++) {
733
-        s->combine_buffer[y] += s->color_buffer[0][y];
734
-        for (x = 1; x < s->nb_display_channels; x++) {
733
+        for (x = 0; x < s->nb_display_channels; x++) {
735 734
             s->combine_buffer[y] += s->color_buffer[x][y];
736 735
         }
737 736
     }