aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert McQueen <robert.mcqueen@collabora.co.uk>2010-05-27 16:21:26 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-05-27 16:21:26 +0800
commit6caef8aaf683117fb559a8c3c98e001a782914a4 (patch)
tree567666f014a93b08b83c7d2de8e0f49548523c1b
parentc75bdbbfc79d0489051bb5f87227647157476433 (diff)
downloadgsoc2013-empathy-6caef8aaf683117fb559a8c3c98e001a782914a4.tar
gsoc2013-empathy-6caef8aaf683117fb559a8c3c98e001a782914a4.tar.gz
gsoc2013-empathy-6caef8aaf683117fb559a8c3c98e001a782914a4.tar.bz2
gsoc2013-empathy-6caef8aaf683117fb559a8c3c98e001a782914a4.tar.lz
gsoc2013-empathy-6caef8aaf683117fb559a8c3c98e001a782914a4.tar.xz
gsoc2013-empathy-6caef8aaf683117fb559a8c3c98e001a782914a4.tar.zst
gsoc2013-empathy-6caef8aaf683117fb559a8c3c98e001a782914a4.zip
fix 0-byte logfile crash (#619736)
-rw-r--r--libempathy/empathy-log-store-empathy.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c
index 2088fca03..1aa8c049e 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);
}