avfilter/avf_showspectrum: fix null pointer dereference if allocation fails
authorPaul B Mahol <onemda@gmail.com>
Sat, 2 Jan 2016 10:49:15 +0000 (11:49 +0100)
committerPaul B Mahol <onemda@gmail.com>
Sat, 2 Jan 2016 17:53:09 +0000 (18:53 +0100)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
libavfilter/avf_showspectrum.c

index b7ee266..a19885b 100644 (file)
@@ -194,12 +194,16 @@ static av_cold void uninit(AVFilterContext *ctx)
 
     av_freep(&s->combine_buffer);
     av_rdft_end(s->rdft);
-    for (i = 0; i < s->nb_display_channels; i++)
-        av_freep(&s->rdft_data[i]);
+    if (s->rdft_data) {
+        for (i = 0; i < s->nb_display_channels; i++)
+            av_freep(&s->rdft_data[i]);
+    }
     av_freep(&s->rdft_data);
     av_freep(&s->window_func_lut);
-    for (i = 0; i < s->nb_display_channels; i++)
-        av_freep(&s->magnitudes[i]);
+    if (s->magnitudes) {
+        for (i = 0; i < s->nb_display_channels; i++)
+            av_freep(&s->magnitudes[i]);
+    }
     av_freep(&s->magnitudes);
     av_frame_free(&s->outpicref);
     av_audio_fifo_free(s->fifo);