[glib/gsettings] Bug 595535 - gvariant alignment reading empty file
- From: Ryan Lortie <ryanl src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib/gsettings] Bug 595535 - gvariant alignment reading empty file
- Date: Tue, 29 Sep 2009 14:25:36 +0000 (UTC)
commit ea31b66708f5097188936c7b535b87dca045c1b3
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Sep 29 10:24:55 2009 -0400
Bug 595535 - gvariant alignment reading empty file
glib/gvariant-util.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/glib/gvariant-util.c b/glib/gvariant-util.c
index aa0ea34..c963c93 100644
--- a/glib/gvariant-util.c
+++ b/glib/gvariant-util.c
@@ -2002,6 +2002,8 @@ g_variant_from_file (const GVariantType *type,
GError **error)
{
GMappedFile *mapped;
+ gconstpointer data;
+ gsize size;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@@ -2011,10 +2013,14 @@ g_variant_from_file (const GVariantType *type,
if (mapped == NULL)
return NULL;
- return g_variant_from_data (type,
- g_mapped_file_get_contents (mapped),
- g_mapped_file_get_length (mapped),
- flags,
+ data = g_mapped_file_get_contents (mapped);
+ size = g_mapped_file_get_length (mapped);
+
+ if (size == 0)
+ /* #595535 */
+ data = NULL;
+
+ return g_variant_from_data (type, data, size, flags,
(GDestroyNotify) g_mapped_file_unref,
mapped);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]