[PATCH] D29786: Use pthreads to manage thread-local storage on darwin for leak sanitizer

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 11:45:46 PST 2017


kubamracek added inline comments.


================
Comment at: lib/lsan/lsan_common_mac.cc:35
+  if (ptr == NULL && allocate) {
+    ptr = (int *)malloc(sizeof(0));
+    *ptr = 0;
----------------
Oh.  Then use `sizeof(*ptr)`.  It's completely non-obvious what `sizeof(0)` evaluates to (and I doubt it's guaranteed to equal `sizeof(int)`.

Also, shouldn't this be `InternalAlloc` instead of `malloc`?  But you probably know better than me here.


https://reviews.llvm.org/D29786





More information about the llvm-commits mailing list