diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-05-05 16:29:03 -0400 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-05-05 16:29:03 -0400 |
commit | a7efd0d30918022e6221ee7cafb63705b3e3c528 (patch) | |
tree | 976862b9ee24448df5fdc78fa7bc1a96bcfdaa39 | |
parent | 260e43c90d77926327faad4488beb44e629b71a5 (diff) |
Make Pigding store robust to empty file
-rw-r--r-- | telepathy-logger/log-store-pidgin.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/telepathy-logger/log-store-pidgin.c b/telepathy-logger/log-store-pidgin.c index 421e99e..e865647 100644 --- a/telepathy-logger/log-store-pidgin.c +++ b/telepathy-logger/log-store-pidgin.c @@ -672,7 +672,7 @@ log_store_pidgin_get_events_for_files (TplLogStore *self, GRegex *regex; GMatchInfo *match_info; - gchar **hits; + gchar **hits = NULL; gboolean is_html = FALSE; filename = (gchar *) l->data; @@ -731,10 +731,14 @@ log_store_pidgin_get_events_for_files (TplLogStore *self, 0, 0, NULL); } - g_regex_match (regex, lines[0], 0, &match_info); - hits = g_match_info_fetch_all (match_info); + if (lines[0] != NULL) + { + g_regex_match (regex, lines[0], 0, &match_info); + hits = g_match_info_fetch_all (match_info); + + g_match_info_free (match_info); + } - g_match_info_free (match_info); g_regex_unref (regex); if (hits == NULL) @@ -970,7 +974,7 @@ _log_store_pidgin_search_in_files (TplLogStorePidgin *self, GMappedFile *file; gsize length; gchar *contents; - gchar *contents_casefold; + gchar *contents_casefold = NULL; filename = l->data; @@ -980,10 +984,15 @@ _log_store_pidgin_search_in_files (TplLogStorePidgin *self, length = g_mapped_file_get_length (file); contents = g_mapped_file_get_contents (file); - contents_casefold = g_utf8_casefold (contents, length); + + if (contents != NULL) + contents_casefold = g_utf8_casefold (contents, length); g_mapped_file_unref (file); + if (contents_casefold == NULL) + continue; + if (strstr (contents_casefold, text_casefold)) { TplLogSearchHit *hit; |