[empathy/gnome-2-30] fix 0-byte logfile crash (#619736)



commit 5a94d355b1f9243170b3dc8b98d1d0333a6bd1ea
Author: Robert McQueen <robert mcqueen collabora co uk>
Date:   Thu May 27 10:21:26 2010 +0200

    fix 0-byte logfile crash (#619736)

 libempathy/empathy-log-store-empathy.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c
index 2088fca..1aa8c04 100644
--- a/libempathy/empathy-log-store-empathy.c
+++ b/libempathy/empathy-log-store-empathy.c
@@ -620,20 +620,22 @@ log_store_empathy_search_new (EmpathyLogStore *self,
       gchar *filename;
       GMappedFile *file;
       gsize length;
-      gchar *contents;
-      gchar *contents_casefold;
+      gchar *contents = NULL;
+      gchar *contents_casefold = NULL;
 
       filename = l->data;
 
       file = g_mapped_file_new (filename, FALSE, NULL);
-      if (!file)
-        continue;
+      if (file == NULL)
+        goto drinking_island;
 
       length = g_mapped_file_get_length (file);
       contents = g_mapped_file_get_contents (file);
-      contents_casefold = g_utf8_casefold (contents, length);
 
-      g_mapped_file_unref (file);
+      if (length == 0 || contents == NULL)
+        goto drinking_island;
+
+      contents_casefold = g_utf8_casefold (contents, length);
 
       if (strstr (contents_casefold, text_casefold))
         {
@@ -649,6 +651,10 @@ log_store_empathy_search_new (EmpathyLogStore *self,
             }
         }
 
+drinking_island:
+      if (file != NULL)
+        g_mapped_file_unref (file);
+
       g_free (contents_casefold);
       g_free (filename);
     }



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