rtspclientsink: make sure not to use freed string
authorTim-Philipp Müller <tim@centricular.com>
Mon, 2 Apr 2018 11:35:04 +0000 (12:35 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Mon, 2 Apr 2018 11:35:04 +0000 (12:35 +0100)
Set transport string to NULL after freeing it, so that
at worst we get a NULL pointer if constructing a new
transport string fails (which shouldn't really fail here).
Also check return value of that, just in case.

CID 1433768.

gst/rtsp-sink/gstrtspclientsink.c

index a96a627..f400a85 100644 (file)
@@ -3966,9 +3966,13 @@ gst_rtsp_client_sink_setup_streams (GstRTSPClientSink * sink, gboolean async)
      * the request headers instead of the previous, incomplete one.
      */
     g_free (transports);
+    transports = NULL;
     res = gst_rtsp_client_sink_create_transports_string (sink, context, family,
         protocols & protocol_masks[mask], cur_profile, &transports);
 
+    if (res < 0 || transports == NULL)
+      goto setup_transport_failed;
+
     /* select transport */
     gst_rtsp_message_take_header (&request, GST_RTSP_HDR_TRANSPORT, transports);