summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKuba Brecka <kuba.brecka@gmail.com>2016-04-14 09:05:19 +0000
committerKuba Brecka <kuba.brecka@gmail.com>2016-04-14 09:05:19 +0000
commit069018ca7afd04b1ca67d2311241c92d8878ff65 (patch)
tree3aa62bf959f7a7bd9b946905c0eb697d54eb5de2 /lib
parentf2c7c4a444580fb66172e31d07456b57b5caa12d (diff)
[tsan] Fix size reporting for OS X zone allocator with 0-sized allocations
The custom zone implementation for OS X must not return 0 (even for 0-sized allocations). Returning 0 indicates that the pointer doesn't belong to the zone. This can break existing applications. The underlaying allocator allocates 1 byte for 0-sized allocations anyway, so returning 1 in this case is okay. Differential Revision: http://reviews.llvm.org/D19100 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266283 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/tsan/rtl/tsan_malloc_mac.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/tsan/rtl/tsan_malloc_mac.cc b/lib/tsan/rtl/tsan_malloc_mac.cc
index 7fd94273c..1366384f7 100644
--- a/lib/tsan/rtl/tsan_malloc_mac.cc
+++ b/lib/tsan/rtl/tsan_malloc_mac.cc
@@ -53,7 +53,8 @@ using namespace __tsan;
SCOPED_INTERCEPTOR_RAW(free, ptr); \
user_free(thr, pc, ptr)
#define COMMON_MALLOC_SIZE(ptr) \
- uptr size = user_alloc_usable_size(ptr);
+ uptr size = user_alloc_usable_size(ptr); \
+ if (size == 0) size = 1;
#define COMMON_MALLOC_FILL_STATS(zone, stats)
#define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \
(void)zone_name; \