plugins/elements/gstfilesrc.c: Fix memory leak.
authorEdward Hervey <bilboed@bilboed.com>
Mon, 24 Nov 2008 11:56:44 +0000 (11:56 +0000)
committerEdward Hervey <bilboed@bilboed.com>
Mon, 24 Nov 2008 11:56:44 +0000 (11:56 +0000)
Original commit message from CVS:
* plugins/elements/gstfilesrc.c: (gst_file_src_uri_set_uri):
Fix memory leak.

ChangeLog
plugins/elements/gstfilesrc.c

index f3bc8ff..bcc14cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-24  Edward Hervey  <edward.hervey@collabora.co.uk>
+
+       * plugins/elements/gstfilesrc.c: (gst_file_src_uri_set_uri):
+       Fix memory leak.
+
 2008-11-24  Sebastian Dröge  <sebastian.droege@collabora.co.uk>
 
        Patch by: Simon Holm Thøgersen <odie at cs dot aau dot dk>
index d9bc699..2d2ec41 100644 (file)
@@ -1101,7 +1101,7 @@ static gboolean
 gst_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
 {
   gchar *location, *hostname = NULL;
-  gboolean ret;
+  gboolean ret = FALSE;
   GstFileSrc *src = GST_FILE_SRC (handler);
 
   if (strcmp (uri, "file://") == 0) {
@@ -1116,17 +1116,13 @@ gst_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
 
   if (!location) {
     GST_WARNING_OBJECT (src, "Invalid URI '%s' for filesrc", uri);
-    return FALSE;
+    goto beach;
   }
 
-  if (hostname) {
-    if (strcmp (hostname, "localhost")) {
-      /* Only 'localhost' is permitted */
-      GST_WARNING_OBJECT (src, "Invalid hostname '%s' for filesrc", hostname);
-      g_free (hostname);
-      return FALSE;
-    }
-    g_free (hostname);
+  if ((hostname) && (strcmp (hostname, "localhost"))) {
+    /* Only 'localhost' is permitted */
+    GST_WARNING_OBJECT (src, "Invalid hostname '%s' for filesrc", hostname);
+    goto beach;
   }
 #ifdef G_OS_WIN32
   /* Unfortunately, g_filename_from_uri() doesn't handle some UNC paths
@@ -1139,7 +1135,12 @@ gst_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
 #endif
 
   ret = gst_file_src_set_location (src, location);
-  g_free (location);
+
+beach:
+  if (location)
+    g_free (location);
+  if (hostname)
+    g_free (hostname);
 
   return ret;
 }