tracker r3091 - in trunk: . src/tracker-indexer



Author: carlosg
Date: Mon Mar 16 17:07:44 2009
New Revision: 3091
URL: http://svn.gnome.org/viewvc/tracker?rev=3091&view=rev

Log:
2009-03-16  Carlos Garnacho  <carlos imendio com>

        * src/tracker-indexer/tracker-indexer.c (handle_metadata_add): Make
        sure that we allocate enough space for the tags that are going to be
        set, and that no empty places are left in between. This fixes both
        memory corruption and strange behavior when saving tags.

Modified:
   trunk/ChangeLog
   trunk/src/tracker-indexer/tracker-indexer.c

Modified: trunk/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer.c	(original)
+++ trunk/src/tracker-indexer/tracker-indexer.c	Mon Mar 16 17:07:44 2009
@@ -2060,8 +2060,8 @@
 {
 	TrackerService *service;
 	TrackerField   *field;
-	guint           service_id, i, j = 0;
-	gchar         **setted_values;
+	guint           service_id, i, j;
+	gchar         **set_values;
 	gchar          *joined, *dirname = NULL, *basename = NULL;
 	gchar         **old_contents;
 	gint            len;
@@ -2148,7 +2148,7 @@
 		}
 	}
 
-	setted_values = g_new0 (gchar *, g_strv_length (values));
+	set_values = g_new0 (gchar *, g_strv_length (values) + 1);
 
 	for (i = 0, j = 0; values[i] != NULL; i++) {
 		g_debug ("Setting metadata: service_type '%s' id '%d' field '%s' value '%s'",
@@ -2163,11 +2163,10 @@
 		}
 
 		tracker_data_update_set_metadata (service, service_id, field, values[i], NULL);
-		setted_values [j++] = values[i];
+		set_values [++j] = values[i];
 	}
-	setted_values [j] = NULL;
-	
-	joined = g_strjoinv (" ", setted_values);
+
+	joined = g_strjoinv (" ", set_values);
 	if (tracker_field_get_filtered (field)) {
 		index_text_no_parsing (indexer,
 				       service_id,
@@ -2187,7 +2186,7 @@
 	}
 
 	/* Not g_strfreev because. It contains the pointers of "values"! */
-	g_free (setted_values);
+	g_free (set_values);
 	g_free (joined);
 
 	return TRUE;



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