[tracker/tracker-0.6] Fixed indexer invalid writes in state_to_string() if string is empty
- From: Martyn James Russell <mr src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/tracker-0.6] Fixed indexer invalid writes in state_to_string() if string is empty
- Date: Wed, 6 May 2009 10:03:21 -0400 (EDT)
commit 82968cee266d7a4e10ff99592c89b15790b3e9f5
Author: Martyn Russell <martyn imendio com>
Date: Wed May 6 12:31:23 2009 +0100
Fixed indexer invalid writes in state_to_string() if string is empty
We assumed the string was always > 3 characters long and we always
truncated the last 3 characters which had the separator " | " appened.
---
src/tracker-indexer/tracker-indexer.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/tracker-indexer/tracker-indexer.c b/src/tracker-indexer/tracker-indexer.c
index 3a25cad..71bc80f 100644
--- a/src/tracker-indexer/tracker-indexer.c
+++ b/src/tracker-indexer/tracker-indexer.c
@@ -2975,6 +2975,7 @@ static gchar *
state_to_string (TrackerIndexerState state)
{
GString *s;
+ gchar *str, *p;
s = g_string_new ("");
@@ -2991,9 +2992,19 @@ state_to_string (TrackerIndexerState state)
s = g_string_append (s, "CLEANUP | ");
}
- s->str[s->len - 3] = '\0';
+ str = g_string_free (s, FALSE);
- return g_string_free (s, FALSE);
+ /* Remove last separator */
+ p = g_utf8_strrchr (str, -1, '|');
+ if (p) {
+ /* Go back one to the space before '|' */
+ p--;
+
+ /* NULL terminate here */
+ *p = '\0';
+ }
+
+ return str;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]