Ubuntu Pastebin

Paste from Marius Gedminas at Fri, 23 Oct 2015 09:44:32 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
diff --git a/src/libtracker-common/tracker-parser-libunistring.c b/src/libtracker-common/tracker-parser-libunistring.c
index 9de6e46..cc4f1ee 100644
--- a/src/libtracker-common/tracker-parser-libunistring.c
+++ b/src/libtracker-common/tracker-parser-libunistring.c
@@ -157,7 +157,8 @@ get_word_info (TrackerParser         *parser,
 }
 
 /* The input word in this method MUST be normalized in NFKD form,
- * and given in UTF-8, where str_length is the byte-length */
+ * and given in UTF-8, where str_length is the byte-length
+ * (note: there is no trailing NUL character!) */
 gboolean
 tracker_parser_unaccent_nfkd_string (gpointer  str,
                                      gsize    *str_length)
@@ -169,7 +170,7 @@ tracker_parser_unaccent_nfkd_string (gpointer  str,
 
 	g_return_val_if_fail (str != NULL, FALSE);
 	g_return_val_if_fail (str_length != NULL, FALSE);
-	g_return_val_if_fail (*str_length > 0, FALSE);
+	g_return_val_if_fail (*str_length >= 0, FALSE);
 
 	word = (gchar *)str;
 	word_length = *str_length;
@@ -209,9 +210,6 @@ tracker_parser_unaccent_nfkd_string (gpointer  str,
 		j += utf8_len;
 	}
 
-	/* Force proper string end */
-	word[j] = '\0';
-
 	/* Set new output length */
 	*str_length = j;
 
@@ -296,6 +294,7 @@ process_word_utf8 (TrackerParser         *parser,
 	if (parser->enable_unaccent &&
 	    type == TRACKER_PARSER_WORD_TYPE_OTHER_UNAC &&
 	    tracker_parser_unaccent_nfkd_string (normalized, &new_word_length)) {
+		normalized[new_word_length] = '\0';
 		/* Log after UNAC stripping */
 		tracker_parser_message_hex ("  After UNAC stripping",
 		                            normalized, new_word_length);
Download as text