webrtc: patch leak caused by early return
authorAlbert Sjölund <alberts@axis.com>
Thu, 16 Mar 2023 12:25:39 +0000 (13:25 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 17 Mar 2023 12:32:23 +0000 (12:32 +0000)
In webrtc_data_channel_send functions, both data and string,
an early return on a non-open datachannel caused it to leak
the buffer used for pushing to appsrc, meaning any buffer
sent after leaving the open state was leaked in full.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4206>

subprojects/gst-plugins-bad/ext/webrtc/webrtcdatachannel.c

index 0260c61..1ca7868 100644 (file)
@@ -871,6 +871,7 @@ webrtc_data_channel_send_data (GstWebRTCDataChannel * base_channel,
     GST_WEBRTC_DATA_CHANNEL_UNLOCK (channel);
     g_set_error (error, GST_WEBRTC_ERROR,
         GST_WEBRTC_ERROR_INVALID_STATE, "channel is not open");
+    gst_buffer_unref (buffer);
     return FALSE;
   }
   GST_WEBRTC_DATA_CHANNEL_UNLOCK (channel);
@@ -945,6 +946,7 @@ webrtc_data_channel_send_string (GstWebRTCDataChannel * base_channel,
     GST_WEBRTC_DATA_CHANNEL_UNLOCK (channel);
     g_set_error (error, GST_WEBRTC_ERROR,
         GST_WEBRTC_ERROR_INVALID_STATE, "channel is not open");
+    gst_buffer_unref (buffer);
     return FALSE;
   }
   GST_WEBRTC_DATA_CHANNEL_UNLOCK (channel);