diff --git a/glib/gslice.c b/glib/gslice.c index 8be5bad48..6ff3597bb 100644 --- a/glib/gslice.c +++ b/glib/gslice.c @@ -1273,13 +1273,18 @@ allocator_add_slab (Allocator *allocator, ChunkLink *chunk; SlabInfo *sinfo; gsize addr, padding, n_chunks, color = 0; - gsize page_size = allocator_aligned_page_size (allocator, SLAB_BPAGE_SIZE (allocator, chunk_size)); + gsize page_size; int errsv; - /* allocate 1 page for the chunks and the slab */ - gpointer aligned_memory = allocator_memalign (page_size, page_size - NATIVE_MALLOC_PADDING); - errsv = errno; - guint8 *mem = aligned_memory; + gpointer aligned_memory; + guint8 *mem; guint i; + + page_size = allocator_aligned_page_size (allocator, SLAB_BPAGE_SIZE (allocator, chunk_size)); + /* allocate 1 page for the chunks and the slab */ + aligned_memory = allocator_memalign (page_size, page_size - NATIVE_MALLOC_PADDING); + errsv = errno; + mem = aligned_memory; + if (!mem) { const gchar *syserr = strerror (errsv);