[glibmm] MemoryInputStream: Correct data loss/corruption with binary data.



commit 9ebcebfdaa42d87ffb2fb0668d1b28d11e161713
Author: Alexey Kosilin <kosilin gmail com>
Date:   Tue Mar 23 18:17:33 2010 +0100

    MemoryInputStream: Correct data loss/corruption with binary data.
    
      * gio/src/memoryinputstream.ccg: add_data(): Use g_memdup() instead of
        g_strdup() on data that could have a null in the middle.
        Bug #609552 (Holger Seelig)

 ChangeLog                     |    8 ++++++++
 gio/src/memoryinputstream.ccg |    2 +-
 2 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b024961..318a30f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-03-23  Alexey Kosilin  <kosilin gmail com>
+
+    MemoryInputStream: Correct data loss/corruption with binary data.
+
+	* gio/src/memoryinputstream.ccg: add_data(): Use g_memdup() instead of 
+    g_strdup() on data that could have a null in the middle.
+    Bug #609552 (Holger Seelig)
+
 2010-03-15  José Alburquerque  <jaalburqu svn gnome org>
 
 	Revert accidentally pushed commits.
diff --git a/gio/src/memoryinputstream.ccg b/gio/src/memoryinputstream.ccg
index 7f6aaf8..0801e02 100644
--- a/gio/src/memoryinputstream.ccg
+++ b/gio/src/memoryinputstream.ccg
@@ -37,7 +37,7 @@ void MemoryInputStream::add_data(const void* data, gssize len)
   if (len < 0)
     data_copy = g_strdup (static_cast<const gchar*>(data));
   else
-    data_copy = g_strndup (static_cast<const gchar*>(data), len);
+    data_copy = static_cast<gchar*>(g_memdup (data, len));
 
   g_memory_input_stream_add_data(gobj(), data_copy, len, g_free);
 }



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