webrtc: Fix double free in webrtc-recvonly-h264 demo
authorPatrick Griffis <pgriffis@igalia.com>
Mon, 24 Oct 2022 17:21:47 +0000 (12:21 -0500)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 24 Oct 2022 22:16:44 +0000 (22:16 +0000)
The "message" signal does not transfer ownership of the GBytes passed
to it so calling g_bytes_unref() on it is incorrect.

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

subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c

index c5ff6c9..bac3a3a 100644 (file)
@@ -490,7 +490,7 @@ soup_websocket_message_cb (G_GNUC_UNUSED SoupWebsocketConnection * connection,
     SoupWebsocketDataType data_type, GBytes * message, gpointer user_data)
 {
   gsize size;
-  gchar *data;
+  const gchar *data;
   gchar *data_string;
   const gchar *type_string;
   JsonNode *root_json;
@@ -502,14 +502,12 @@ soup_websocket_message_cb (G_GNUC_UNUSED SoupWebsocketConnection * connection,
   switch (data_type) {
     case SOUP_WEBSOCKET_DATA_BINARY:
       g_error ("Received unknown binary message, ignoring\n");
-      g_bytes_unref (message);
       return;
 
     case SOUP_WEBSOCKET_DATA_TEXT:
-      data = g_bytes_unref_to_data (message, &size);
+      data = g_bytes_get_data (message, &size);
       /* Convert to NULL-terminated string */
       data_string = g_strndup (data, size);
-      g_free (data);
       break;
 
     default: