[llvm-commits] [compiler-rt] r157176 - /compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc

Dmitry Vyukov dvyukov at google.com
Sun May 20 23:46:27 PDT 2012


Author: dvyukov
Date: Mon May 21 01:46:27 2012
New Revision: 157176

URL: http://llvm.org/viewvc/llvm-project?rev=157176&view=rev
Log:
tsan: add more checks for OOM conditions
tests like to try to malloc((size_t)-1)


Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc?rev=157176&r1=157175&r2=157176&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc Mon May 21 01:46:27 2012
@@ -33,6 +33,8 @@
   if (sz + sizeof(MBlock) < sz)
     return 0;
   MBlock *b = (MBlock*)Alloc(sz + sizeof(MBlock));
+  if (b == 0)
+    return 0;
   b->size = sz;
   void *p = b + 1;
   if (CTX() && CTX()->initialized) {
@@ -63,6 +65,8 @@
   // it seems that some software actually does this.
   if (sz) {
     p2 = user_alloc(thr, pc, sz);
+    if (p2 == 0)
+      return 0;
     if (p) {
       MBlock *b = user_mblock(thr, p);
       internal_memcpy(p2, p, min(b->size, sz));





More information about the llvm-commits mailing list