wpesrc: fix a memory leak of the bytes
authorMatthew Waters <matthew@centricular.com>
Wed, 7 Oct 2020 10:14:55 +0000 (21:14 +1100)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 13 Oct 2020 08:48:05 +0000 (08:48 +0000)
free the previous GBytes if load-bytes is called multiple times
before view creation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1663>

ext/wpe/gstwpesrc.cpp

index c234957..1481ebb 100644 (file)
@@ -405,10 +405,13 @@ gst_wpe_src_configure_web_view (GstWpeSrc * src, WebKitWebView * webview)
 static void
 gst_wpe_src_load_bytes (GstWpeSrc * src, GBytes * bytes)
 {
-  if (src->view && GST_STATE (GST_ELEMENT_CAST (src)) > GST_STATE_NULL)
+  if (src->view && GST_STATE (GST_ELEMENT_CAST (src)) > GST_STATE_NULL) {
     src->view->loadData (bytes);
-  else
+  } else {
+    if (src->bytes)
+      g_bytes_unref (src->bytes);
     src->bytes = g_bytes_ref (bytes);
+  }
 }
 
 static gboolean