fix leak in a test, make the sanitizer bot green
authorKostya Serebryany <kcc@google.com>
Mon, 21 Dec 2015 19:09:01 +0000 (19:09 +0000)
committerKostya Serebryany <kcc@google.com>
Mon, 21 Dec 2015 19:09:01 +0000 (19:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256179 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Support/TrailingObjectsTest.cpp

index 2b8ab4c5fb83a763bce56ffbfc6e12566c4ef328..4c05d665f98b5af15759070a3801393d7b5c05e2 100644 (file)
@@ -164,7 +164,8 @@ TEST(TrailingObjects, ThreeArg) {
             sizeof(double) + sizeof(short) + 3 * sizeof(bool));
   EXPECT_EQ(sizeof(Class3),
             llvm::RoundUpToAlignment(1, llvm::alignOf<double>()));
-  Class3 *C = reinterpret_cast<Class3 *>(::operator new(1000));
+  std::unique_ptr<char[]> P(new char[1000]);
+  Class3 *C = reinterpret_cast<Class3 *>(P.get());
   EXPECT_EQ(C->getTrailingObjects<double>(), reinterpret_cast<double *>(C + 1));
   EXPECT_EQ(C->getTrailingObjects<short>(),
             reinterpret_cast<short *>(reinterpret_cast<double *>(C + 1) + 1));