From da18a8d93d6d1ac7650835bd0855bf703429c4bd Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 7 Oct 2020 21:14:55 +1100 Subject: [PATCH] wpesrc: fix a memory leak of the bytes free the previous GBytes if load-bytes is called multiple times before view creation. Part-of: --- ext/wpe/gstwpesrc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ext/wpe/gstwpesrc.cpp b/ext/wpe/gstwpesrc.cpp index c23495710b..1481ebb21b 100644 --- a/ext/wpe/gstwpesrc.cpp +++ b/ext/wpe/gstwpesrc.cpp @@ -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