@@ -3290,7 +3290,7 @@ Void_t *public_mALLOc(size_t bytes)
victim = tcache_malloc(bytes);
if (victim)
- goto out;
+ return victim;
ar_ptr = arena_get(bytes);
if (!ar_ptr)
@@ -3302,9 +3302,6 @@ Void_t *public_mALLOc(size_t bytes)
}
arena_unlock(ar_ptr);
assert(!victim || chunk_is_mmapped(mem2chunk(victim)) || ar_ptr == arena_for_chunk(mem2chunk(victim)));
-out:
- if (perturb_byte)
- alloc_perturb(victim, bytes);
return victim;
}
@@ -287,6 +287,8 @@ static void *tcache_malloc(size_t size)
void *p = chunk2mem(victim);
cache->tc_size -= chunksize(victim);
cache->tc_count--;
+ if (perturb_byte)
+ alloc_perturb(p, size);
return p;
}
@@ -333,12 +335,11 @@ static void *tcache_malloc(size_t size)
}
arena_unlock(arena);
assert(!victim || arena == arena_for_chunk(mem2chunk(victim)));
+ if (perturb_byte)
+ alloc_perturb(victim, size);
return victim;
}
-/*
- * returns 1 if object was freed
- */
static void tcache_free(mchunkptr p)
{
struct thread_cache *cache;
@@ -367,6 +368,8 @@ static void tcache_free(mchunkptr p)
malloc_printerr(check_action, "invalid tcache entry", chunk2mem(p));
return;
}
+ if (perturb_byte)
+ free_perturb(p, size - 2 * SIZE_SZ);
add_to_bin(bin, p);
if (cache->tc_size > CACHE_SIZE)
tcache_gc(cache);