[compiler-rt] r196263 - [Sanitizer] Fix a bug introduced in r196112. Add a test.
Alexey Samsonov
samsonov at google.com
Tue Dec 3 01:21:08 PST 2013
Author: samsonov
Date: Tue Dec 3 03:21:08 2013
New Revision: 196263
URL: http://llvm.org/viewvc/llvm-project?rev=196263&view=rev
Log:
[Sanitizer] Fix a bug introduced in r196112. Add a test.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=196263&r1=196262&r2=196263&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Tue Dec 3 03:21:08 2013
@@ -320,7 +320,7 @@ template<typename T>
class InternalMmapVector {
public:
explicit InternalMmapVector(uptr initial_capacity) {
- capacity_ = Min(initial_capacity, (uptr)1);
+ capacity_ = Max(initial_capacity, (uptr)1);
size_ = 0;
data_ = (T *)MmapOrDie(capacity_ * sizeof(T), "InternalMmapVector");
}
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc?rev=196263&r1=196262&r2=196263&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc Tue Dec 3 03:21:08 2013
@@ -113,6 +113,9 @@ TEST(SanitizerCommon, InternalMmapVector
vector.pop_back();
EXPECT_EQ((uptr)i, vector.size());
}
+ InternalMmapVector<uptr> empty_vector(0);
+ CHECK_GT(empty_vector.capacity(), 0U);
+ CHECK_EQ(0U, empty_vector.size());
}
void TestThreadInfo(bool main) {
More information about the llvm-commits
mailing list