garray: initialize allocated size in g_byte_array_new_take()
authorAleksander Morgado <aleksander@aleksander.es>
Wed, 8 Oct 2014 18:37:42 +0000 (20:37 +0200)
committerAleksander Morgado <aleksander@aleksander.es>
Wed, 8 Oct 2014 18:51:47 +0000 (20:51 +0200)
commit549e7b0de62b9f31825f0c24f41cfa7eaad97360
treed76ba6078b1cb10b9a0dea5cea48061a0122d924
parentde82b641b05ee32812d945a9d4ecd1c1bbc3401e
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