Bug 724590 - GSlice slab_stack corruption
authorJohn Ralls <jralls@ceridwen.us>
Mon, 17 Feb 2014 23:51:38 +0000 (15:51 -0800)
committerJohn Ralls <jralls@ceridwen.us>
Wed, 16 Apr 2014 00:27:16 +0000 (17:27 -0700)
Dereference allocation->contention_counters before trying to take the
address of an element.

glib/gslice.c

index 0563d80..2c5f4fb 100644 (file)
@@ -715,7 +715,8 @@ static ChunkLink*
 magazine_cache_pop_magazine (guint  ix,
                              gsize *countp)
 {
-  g_mutex_lock_a (&allocator->magazine_mutex, &allocator->contention_counters[ix]);
+  guint *counters = allocator->contention_counters;
+  g_mutex_lock_a (&allocator->magazine_mutex, &counters[ix]);
   if (!allocator->magazines[ix])
     {
       guint magazine_threshold = allocator_get_magazine_threshold (allocator, ix);