diff options
| author | Kuba Brecka <kuba.brecka@gmail.com> | 2016-04-30 07:14:41 +0000 |
|---|---|---|
| committer | Kuba Brecka <kuba.brecka@gmail.com> | 2016-04-30 07:14:41 +0000 |
| commit | 9ccde5ace4c1905f328ca48a3207e2b5ba756533 (patch) | |
| tree | d580500fb539fae93c9f53498197bb598e701655 /compiler-rt/lib/tsan/rtl/tsan_malloc_mac.cc | |
| parent | eb5bd02a7ec2c0a5d10d8f68c5c40c00776824fb (diff) | |
| download | bcm5719-llvm-9ccde5ace4c1905f328ca48a3207e2b5ba756533.tar.gz bcm5719-llvm-9ccde5ace4c1905f328ca48a3207e2b5ba756533.zip | |
[tsan] Return 0 from malloc_size for non-malloc'd pointers
In http://reviews.llvm.org/D19100, I introduced a bug: On OS X, existing programs rely on malloc_size() to detect whether a pointer comes from heap memory (malloc_size returns non-zero) or not. We have to distinguish between a zero-sized allocation (where we need to return 1 from malloc_size, due to other binary compatibility reasons, see http://reviews.llvm.org/D19100), and pointers that are not returned from malloc at all.
Differential Revision: http://reviews.llvm.org/D19653
llvm-svn: 268157
Diffstat (limited to 'compiler-rt/lib/tsan/rtl/tsan_malloc_mac.cc')
| -rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_malloc_mac.cc | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_malloc_mac.cc b/compiler-rt/lib/tsan/rtl/tsan_malloc_mac.cc index 1366384f723..7fd94273c31 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_malloc_mac.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_malloc_mac.cc @@ -53,8 +53,7 @@ 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); \ - if (size == 0) size = 1; + uptr size = user_alloc_usable_size(ptr); #define COMMON_MALLOC_FILL_STATS(zone, stats) #define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \ (void)zone_name; \ |

