[tracker] tracker-fts: protect better against invalid UTF-8.



commit dde8ffb48b684f4265258fcc1f43d40095069b3e
Author: Carlos Garnacho <carlos lanedo com>
Date:   Fri Mar 5 14:49:02 2010 +0100

    tracker-fts: protect better against invalid UTF-8.
    
    Also, remove 2 mistakenly added dbus g_print()s.

 src/libtracker-fts/tracker-parser.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-fts/tracker-parser.c b/src/libtracker-fts/tracker-parser.c
index d83874e..f48a73c 100644
--- a/src/libtracker-fts/tracker-parser.c
+++ b/src/libtracker-fts/tracker-parser.c
@@ -143,7 +143,6 @@ strip_word (const gchar *str,
             gint         length,
             guint32     *len)
 {
-	g_print ("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
 #ifdef HAVE_UNAC
 	gchar *s = NULL;
 
@@ -443,13 +442,14 @@ parser_next (TrackerParser *parser,
 		parser->cursor = parser->txt + *byte_offset_end;
 
 		processed_word = tracker_parser_process_word (parser, utf8, bytes, do_strip);
-
 		g_free (utf8);
 
-		parser->word_length = strlen (processed_word);
-		parser->word = processed_word;
+		if (processed_word) {
+			parser->word_length = strlen (processed_word);
+			parser->word = processed_word;
 
-		return TRUE;
+			return TRUE;
+		}
 
 	}
 
@@ -560,8 +560,6 @@ tracker_parser_process_word (TrackerParser *parser,
 	g_return_val_if_fail (parser != NULL, NULL);
 	g_return_val_if_fail (word != NULL, NULL);
 
-	g_print ("process word?\n");
-
 	str = NULL;
 	stripped_word = NULL;
 
@@ -589,6 +587,10 @@ tracker_parser_process_word (TrackerParser *parser,
 			g_free (stripped_word);
 		}
 
+		if (!str) {
+			return NULL;
+		}
+
 		if (!parser->enable_stemmer) {
 			return str;
 		}



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