[glib/resources] Guarantee that non-compressed files have and (internal) zero padding
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/resources] Guarantee that non-compressed files have and (internal) zero padding
- Date: Thu, 22 Dec 2011 09:43:02 +0000 (UTC)
commit e6495e14c02dc4140e2a4c73e995d7ff22d7414b
Author: Alexander Larsson <alexl redhat com>
Date: Thu Dec 22 10:42:02 2011 +0100
Guarantee that non-compressed files have and (internal) zero padding
gio/glib-compile-resources.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c
index 51b1292..5c78d5e 100644
--- a/gio/glib-compile-resources.c
+++ b/gio/glib-compile-resources.c
@@ -226,7 +226,7 @@ end_element (GMarkupParseContext *context,
else
real_file = g_strdup (file);
- if (!g_file_get_contents (real_file, &data->content, &data->content_size, &my_error))
+ if (!g_file_get_contents (real_file, &data->content, &data->size, &my_error))
{
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
_("Error reading file %s: %s"),
@@ -234,7 +234,8 @@ end_element (GMarkupParseContext *context,
g_clear_error (&my_error);
return;
}
- data->size = data->content_size;
+ /* Include zero termination in content_size for uncompressed files (but not in size) */
+ data->content_size = data->size + 1;
if (state->compressed)
{
@@ -243,7 +244,7 @@ end_element (GMarkupParseContext *context,
g_zlib_compressor_new (G_ZLIB_COMPRESSOR_FORMAT_ZLIB, 9);
GOutputStream *out2 = g_converter_output_stream_new (out, G_CONVERTER (compressor));
- if (!g_output_stream_write_all (out2, data->content, data->content_size,
+ if (!g_output_stream_write_all (out2, data->content, data->size,
NULL, NULL, NULL) ||
!g_output_stream_close (out2, NULL, NULL))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]