[glib/glib-2-42] garray: initialize allocated size in g_byte_array_new_take()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-42] garray: initialize allocated size in g_byte_array_new_take()
- Date: Fri, 10 Oct 2014 10:43:47 +0000 (UTC)
commit bf44b592c8c6d33b35c03015ac6ff56c1992222b
Author: Aleksander Morgado <aleksander aleksander es>
Date: Wed Oct 8 20:37:42 2014 +0200
garray: initialize allocated size in g_byte_array_new_take()
Internal allocation size (array->alloc) was being kept to 0 when a new
GByteArray was created from an already existing heap-allocated buffer.
Among other things, this was making g_byte_array_set_size() fully clear all
the buffer contents (not just the newly allocated memory) when
G_DEBUG=gc-friendly was being used...
if (G_UNLIKELY (g_mem_gc_friendly))
memset (array->data + array->alloc, 0, want_alloc - array->alloc);
https://bugzilla.gnome.org/show_bug.cgi?id=738170
glib/garray.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/glib/garray.c b/glib/garray.c
index 14e046f..8a94720 100644
--- a/glib/garray.c
+++ b/glib/garray.c
@@ -1589,6 +1589,7 @@ g_byte_array_new_take (guint8 *data,
real->data = data;
real->len = len;
+ real->alloc = len;
return array;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]