From 925bbaea76b91bd307634908cfd6902f99804544 Mon Sep 17 00:00:00 2001 From: Aliaksey Kandratsenka Date: Sat, 16 Nov 2013 14:01:38 -0800 Subject: [PATCH] actually check result of CheckAddressBits Previously call to CheckAddressBits was made but nothing was done to it's result. I've also make sure that actual size is used in checks and in bumping up of TCMalloc_SystemTaken. --- src/system-alloc.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/system-alloc.cc b/src/system-alloc.cc index 52e1094..e09e072 100644 --- a/src/system-alloc.cc +++ b/src/system-alloc.cc @@ -495,17 +495,17 @@ void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size, // Enforce minimum alignment if (alignment < sizeof(MemoryAligner)) alignment = sizeof(MemoryAligner); + size_t actual_size_storage; + if (actual_size == NULL) { + actual_size = &actual_size_storage; + } + void* result = sys_alloc->Alloc(size, actual_size, alignment); if (result != NULL) { - if (actual_size) { + CHECK_CONDITION( CheckAddressBits( - reinterpret_cast(result) + *actual_size - 1); - TCMalloc_SystemTaken += *actual_size; - } else { - CheckAddressBits( - reinterpret_cast(result) + size - 1); - TCMalloc_SystemTaken += size; - } + reinterpret_cast(result) + *actual_size - 1)); + TCMalloc_SystemTaken += *actual_size; } return result; }