[libgsf] GsfInputMemory: Handle zero-sized files better.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [libgsf] GsfInputMemory: Handle zero-sized files better.
- Date: Sat, 25 Apr 2009 14:14:10 -0400 (EDT)
commit 58e66b05124cb0e34f83969cbfab59cd7814c5be
Author: Morten Welinder <terra gnome org>
Date: Sat Apr 25 14:14:32 2009 -0400
GsfInputMemory: Handle zero-sized files better.
---
ChangeLog | 6 ++++++
NEWS | 9 ++++++---
gsf/gsf-input-memory.c | 10 +++++-----
3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f85f5a7..c3de3e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-04-25 Morten Welinder <terra gnome org>
+
+ * gsf/gsf-input-memory.c (gsf_input_memory_new_clone): Fix
+ preconditions. Always allocate at least one byte. Avoid cast.
+ Fixes #580228.
+
2009-04-17 Morten Welinder <terra gnome org>
* gsf/gsf-output.c (gsf_output_set_error): Fix allocation method
diff --git a/NEWS b/NEWS
index 294c6ea..9afe899 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,7 @@
libgsf 1.14.12
Andreas:
- * also read user defined OpenDocument metadata
+ * Also read user defined OpenDocument metadata
Christian Persch:
* Fix allocation method problem. [#579155]
@@ -13,13 +13,16 @@ J.H.M. Dassen (Ray):
Jody :
* Handle small-block files that are not block aligned. [#572290]
- * Deprecate gsf_timestamp_parse and replace it with gsf_timestamp_from_string.
+ * Deprecate gsf_timestamp_parse and replace it with
+ gsf_timestamp_from_string.
* Gtk-Doc fixes.
- * Fix handling of namespace declared default and prefix. (SpreadsheetML-2003)
+ * Fix handling of namespace declared default and prefix.
+ (Such as in SpreadsheetML-2003)
Morten:
* Handle malformed xml better. [#568994]
* Drop characters that xml 1.0 cannot represent. [#568919]
+ * Fix problem loading zero-sized files. [#580228]
--------------------------------------------------------------------------
libgsf 1.14.11
diff --git a/gsf/gsf-input-memory.c b/gsf/gsf-input-memory.c
index c2ffc24..98a51a0 100644
--- a/gsf/gsf-input-memory.c
+++ b/gsf/gsf-input-memory.c
@@ -93,21 +93,21 @@ GsfInput *
gsf_input_memory_new_clone (guint8 const *buf, gsf_off_t length)
{
GsfInputMemory *mem = NULL;
- guint8 *cpy;
+ void *cpy;
- g_return_val_if_fail (buf != NULL, NULL);
- g_return_val_if_fail (length > 0, NULL);
+ g_return_val_if_fail (buf != NULL || length == 0, NULL);
+ g_return_val_if_fail (length >= 0, NULL);
mem = g_object_new (GSF_INPUT_MEMORY_TYPE, NULL);
if (G_UNLIKELY (NULL == mem)) return NULL;
- cpy = g_try_malloc (length * sizeof (guint8));
+ cpy = g_try_malloc (MAX (1, length) * sizeof (guint8));
if (cpy == NULL) {
g_object_unref (mem);
return NULL;
}
memcpy (cpy, buf, length);
- mem->shared = gsf_shared_memory_new ((void *)cpy, length, TRUE);
+ mem->shared = gsf_shared_memory_new (cpy, length, TRUE);
gsf_input_set_size (GSF_INPUT (mem), length);
return GSF_INPUT (mem);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]