imagesequencesrc; Fix leaks
authorEdward Hervey <edward@centricular.com>
Thu, 3 Nov 2022 13:08:57 +0000 (14:08 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 4 Nov 2022 17:59:21 +0000 (17:59 +0000)
* The path was leaked
* The custom buffer was never freed

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

subprojects/gst-plugins-good/gst/multifile/gstimagesequencesrc.c

index ce289b7..90dc9ff 100644 (file)
@@ -144,7 +144,7 @@ static gboolean
 gst_image_sequence_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
     GError ** err)
 {
-  gchar *hostname = NULL, *location = NULL, *tmp;
+  gchar *hostname = NULL, *location = NULL, *path, *tmp;
   gboolean ret = FALSE;
   GstImageSequenceSrc *self = GST_IMAGE_SEQUENCE_SRC (handler);
   GstUri *ruri = gst_uri_from_string (uri);
@@ -160,9 +160,11 @@ gst_image_sequence_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
   LOCK (self);
   g_clear_pointer (&self->uri, gst_uri_unref);
   self->uri = ruri;
-  tmp = gst_filename_to_uri (gst_uri_get_path (ruri), err);
+  path = gst_uri_get_path (ruri);
+  tmp = gst_filename_to_uri (path, err);
   location = g_filename_from_uri (tmp, &hostname, err);
   g_free (tmp);
+  g_free (path);
   query = gst_uri_get_query_table (ruri);
   if (!location || (err != NULL && *err != NULL)) {
     GST_WARNING_OBJECT (self, "Invalid URI '%s' for imagesequencesrc: %s", uri,
@@ -606,7 +608,7 @@ gst_image_sequence_src_create (GstPushSrc * src, GstBuffer ** buffer)
   if (!ret)
     goto handle_error;
 
-  buf = gst_buffer_new_wrapped_full (0, data, size, 0, size, NULL, g_free);
+  buf = gst_buffer_new_wrapped (data, size);
 
   if (!self->caps) {
     GstCaps *caps;