tracker r3167 - in trunk: . src/tracker-extract



Author: carlosg
Date: Thu Apr  2 16:27:37 2009
New Revision: 3167
URL: http://svn.gnome.org/viewvc/tracker?rev=3167&view=rev

Log:
2009-04-02  Carlos Garnacho  <carlos imendio com>

        * src/tracker-extract/tracker-extract-gstreamer.c
        (tracker_extract_gstreamer): Fix a leak and a possible memory
        corruption.
        * src/tracker-extract/tracker-extract-mp3.c (extract_mp3): Do not make
        id3 tags parsers read invalid memory if file size is above
        MAX_FILE_READ.
        * src/tracker-extract/tracker-extract-png.c (extract_png): Free
        correctly the ending info pointer.
        * src/tracker-extract/tracker-extract.c (get_file_metadata): Plug a
        leak, caused when no extractor was found.
        * src/tracker-extract/tracker-main.c: Initialize the quit timeout ID
        to 0, so we don't try to remove nonexistent sources.

Modified:
   trunk/ChangeLog
   trunk/src/tracker-extract/tracker-extract-gstreamer.c
   trunk/src/tracker-extract/tracker-extract-mp3.c
   trunk/src/tracker-extract/tracker-extract-png.c
   trunk/src/tracker-extract/tracker-extract.c
   trunk/src/tracker-extract/tracker-main.c

Modified: trunk/src/tracker-extract/tracker-extract-gstreamer.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-gstreamer.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-gstreamer.c	Thu Apr  2 16:27:37 2009
@@ -639,7 +639,6 @@
 			   ExtractMime	type)
 {
 	MetadataExtractor *extractor;
-	gchar		  *mrl;
 
 	g_return_if_fail (uri);
 	g_return_if_fail (metadata);
@@ -732,7 +731,6 @@
 	extractor->bus = gst_pipeline_get_bus (GST_PIPELINE (extractor->pipeline));
 	gst_bus_add_watch (extractor->bus, metadata_bus_async_cb, extractor);
 
-	mrl = g_strconcat ("file://", uri, NULL);
 	g_object_set (G_OBJECT (extractor->filesrc), "location", uri, NULL);
 
 	gst_element_set_state (extractor->pipeline, GST_STATE_PAUSED);
@@ -741,12 +739,6 @@
 
 	extract_metadata (extractor, metadata);
 
-	gst_element_set_state (extractor->pipeline, GST_STATE_NULL);
-	gst_object_unref (extractor->bus);
-	gst_object_unref (GST_OBJECT (extractor->pipeline));
-	g_main_loop_unref (extractor->loop);
-	g_slice_free (MetadataExtractor, extractor);
-
 	/* Save embedded art */
 	if (extractor->album_art_data && extractor->album_art_size) {
 #ifdef HAVE_GDKPIXBUF
@@ -765,6 +757,12 @@
 #endif /* HAVE_GDKPIXBUF */
 	}
 
+	gst_element_set_state (extractor->pipeline, GST_STATE_NULL);
+	gst_object_unref (extractor->bus);
+	gst_object_unref (GST_OBJECT (extractor->pipeline));
+	g_main_loop_unref (extractor->loop);
+	g_slice_free (MetadataExtractor, extractor);
+
 	if (type == EXTRACT_MIME_IMAGE) {
 		if (!g_hash_table_lookup (metadata, "Image:Date")) {
 			struct stat st;

Modified: trunk/src/tracker-extract/tracker-extract-mp3.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-mp3.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-mp3.c	Thu Apr  2 16:27:37 2009
@@ -1513,7 +1513,7 @@
 
 	size = tracker_file_get_size (filename);
 
-	if (size == 0) {
+	if (size == 0 || size > MAX_FILE_READ) {
 		return;
 	}
 

Modified: trunk/src/tracker-extract/tracker-extract-png.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-png.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-png.c	Thu Apr  2 16:27:37 2009
@@ -183,14 +183,12 @@
 		end_ptr = png_create_info_struct (png_ptr);
 		if (!end_ptr) {
 			png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
-			png_destroy_read_struct (&png_ptr, &end_ptr, NULL);
 			tracker_file_close (f, FALSE);
 			return;
 		}
 
 		if (setjmp (png_jmpbuf (png_ptr))) {
-			png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
-			png_destroy_read_struct (&png_ptr, &end_ptr, NULL);
+			png_destroy_read_struct (&png_ptr, &info_ptr, &end_ptr);
 			tracker_file_close (f, FALSE);
 			return;
 		}
@@ -207,8 +205,7 @@
 				   &interlace_type,
 				   &compression_type,
 				   &filter_type)) {
-			png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
-			png_destroy_read_struct (&png_ptr, &end_ptr, NULL);
+			png_destroy_read_struct (&png_ptr, &info_ptr, &end_ptr);
 			tracker_file_close (f, FALSE);
 			return;
 		}
@@ -259,8 +256,7 @@
 			g_free (date);
 		}
 
-		png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
-		png_destroy_read_struct (&png_ptr, &end_ptr, NULL);
+		png_destroy_read_struct (&png_ptr, &info_ptr, &end_ptr);
 		tracker_file_close (f, FALSE);
 	}
 }

Modified: trunk/src/tracker-extract/tracker-extract.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract.c	(original)
+++ trunk/src/tracker-extract/tracker-extract.c	Thu Apr  2 16:27:37 2009
@@ -326,14 +326,16 @@
 				tracker_dbus_request_comment (request_id,
 							      "  Found %d metadata items",
 							      g_hash_table_size (values));
-				
+
 				g_free (path_in_locale);
 				g_free (mime_used);
-				
+
 				return values;
 			}
 		}
 
+		g_free (mime_used);
+
 		tracker_dbus_request_comment (request_id,
 					      "  Could not find any extractors to handle metadata type");
 	} else {

Modified: trunk/src/tracker-extract/tracker-main.c
==============================================================================
--- trunk/src/tracker-extract/tracker-main.c	(original)
+++ trunk/src/tracker-extract/tracker-main.c	Thu Apr  2 16:27:37 2009
@@ -65,7 +65,7 @@
 #define QUIT_TIMEOUT 30 /* 1/2 minutes worth of seconds */
 
 static GMainLoop *main_loop;
-static guint      quit_timeout_id;
+static guint      quit_timeout_id = 0;
 
 static gboolean   version;
 static gint       verbosity = -1;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]