Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_vector.h =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_vector.h +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_vector.h @@ -82,6 +82,10 @@ return; } uptr old_size = Size(); + if (size <= old_size) { + end_ = begin_ + size; + return; + } EnsureSize(size); if (old_size < size) { for (uptr i = old_size; i < size; i++) Index: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_vector_test.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_vector_test.cc +++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_vector_test.cc @@ -39,4 +39,13 @@ } } +TEST(Vector, ResizeReduction) { + Vector v; + v.PushBack(0); + v.PushBack(0); + EXPECT_EQ(v.Size(), 2u); + v.Resize(1); + EXPECT_EQ(v.Size(), 1u); +} + } // namespace __sanitizer