flvmux: Avoid crash when changing caps without both streams
authorJan Alexander Steffens (heftig) <jsteffens@make.tv>
Wed, 19 Jun 2019 10:28:22 +0000 (12:28 +0200)
committerJan Alexander Steffens (heftig) <jsteffens@make.tv>
Wed, 19 Jun 2019 12:36:21 +0000 (14:36 +0200)
mux->video_pad and mux->audio_pad can be NULL if the corresponding pad
has not been requested.

gst/flv/gstflvmux.c

index cbabec7..2269100 100644 (file)
@@ -1486,10 +1486,15 @@ gst_flv_mux_write_header (GstFlvMux * mux)
       caps = gst_flv_mux_prepare_src_caps (mux,
           &header, &metadata, &video_codec_data, &audio_codec_data);
     } else {
+      GstBuffer **video_codec_data_p = NULL, **audio_codec_data_p = NULL;
+
+      if (mux->video_pad && mux->video_pad->info_changed)
+        video_codec_data_p = &video_codec_data;
+      if (mux->audio_pad && mux->audio_pad->info_changed)
+        audio_codec_data_p = &audio_codec_data;
+
       caps = gst_flv_mux_prepare_src_caps (mux,
-          NULL, NULL,
-          (mux->video_pad->info_changed ? &video_codec_data : NULL),
-          (mux->audio_pad->info_changed ? &audio_codec_data : NULL));
+          NULL, NULL, video_codec_data_p, audio_codec_data_p);
     }
   }