|  | diff -aruN a/CFRuntime.c b/CFRuntime.c | 
|  | --- a/CFRuntime.c	2009-02-19 08:32:54.000000000 -0800 | 
|  | +++ b/CFRuntime.c	2011-08-10 16:32:44.000000000 -0700 | 
|  | @@ -73,11 +73,6 @@ | 
|  | CF_INLINE size_t malloc_size(void* memblock) { | 
|  | return _msize(memblock); | 
|  | } | 
|  | -#elif DEPLOYMENT_TARGET_LINUX | 
|  | -#include <malloc.h> | 
|  | -CF_INLINE size_t malloc_size(const void *memblock) { | 
|  | -    return malloc_usable_size((void *)memblock); | 
|  | -} | 
|  | #endif | 
|  |  | 
|  | extern void __HALT(void); | 
|  | @@ -264,12 +259,21 @@ | 
|  | if (NULL == memory) { | 
|  | return NULL; | 
|  | } | 
|  | -#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX | 
|  | +#if DEPLOYMENT_TARGET_WINDOWS | 
|  | // malloc_size won't work if the memory address has been moved | 
|  | // (such as a custom allocator that adds its own metadata | 
|  | // (e.g. under/overflow guard data), so don't attempt to call it | 
|  | // on the allocation return. | 
|  | size_t msize = (usesSystemDefaultAllocator) ? malloc_size(memory) : size; | 
|  | +#elif DEPLOYMENT_TARGET_LINUX | 
|  | +    // On Linux, across various architectures and versions of the GNU | 
|  | +    // C Library, malloc_usable_size has been observed to at times return | 
|  | +    // incorrect values. Since the introspection value-add it provides to | 
|  | +    // CoreFoundation seems to be of limited utility, we eliminate it and | 
|  | +    // simpy use the caller-requested size. In addition, memsetting this | 
|  | +    // small tail block has also been found to cause heap consistency | 
|  | +    // problems. | 
|  | +    size_t msize = size; | 
|  | #else | 
|  | size_t msize = malloc_size(memory); | 
|  | #endif | 
|  | @@ -1098,6 +1100,7 @@ | 
|  | usesSystemDefaultAllocator = (allocator == kCFAllocatorSystemDefault); | 
|  |  | 
|  | if (__CFZombieLevel & (1 << 0)) { | 
|  | +#if !DEPLOYMENT_TARGET_LINUX | 
|  | uint8_t *ptr = (uint8_t *)cf - (usesSystemDefaultAllocator ? 0 : sizeof(CFAllocatorRef)); | 
|  | size_t size = malloc_size(ptr); | 
|  | uint8_t byte = 0xFC; | 
|  | @@ -1109,6 +1112,7 @@ | 
|  | byte = (__CFZombieLevel >> 8) & 0xFF; | 
|  | } | 
|  | memset(ptr, byte, size); | 
|  | +#endif /* !DEPLOYMENT_TARGET_LINUX */ | 
|  | } | 
|  | if (!(__CFZombieLevel & (1 << 4))) { | 
|  | CFAllocatorDeallocate(allocator, (uint8_t *)cf - (usesSystemDefaultAllocator ? 0 : sizeof(CFAllocatorRef))); |