[compiler-rt] 353e5aa - [libFuzzer] Fix leak in unit test.

Matt Morehouse via llvm-commits llvm-commits at lists.llvm.org
Thu May 21 09:02:35 PDT 2020


Author: Matt Morehouse
Date: 2020-05-21T09:02:22-07:00
New Revision: 353e5aa42dfee3f119fd1790509ea35a280295f7

URL: https://github.com/llvm/llvm-project/commit/353e5aa42dfee3f119fd1790509ea35a280295f7
DIFF: https://github.com/llvm/llvm-project/commit/353e5aa42dfee3f119fd1790509ea35a280295f7.diff

LOG: [libFuzzer] Fix leak in unit test.

Added: 
    

Modified: 
    compiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp b/compiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp
index b480e9f0fff5..0e9435ab8fcb 100644
--- a/compiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp
+++ b/compiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp
@@ -1058,24 +1058,24 @@ TEST(Entropic, UpdateFrequency) {
   // Create input corpus with default entropic configuration
   struct EntropicOptions Entropic = {true, 0xFF, 100};
   std::unique_ptr<InputCorpus> C(new InputCorpus("", Entropic));
-  InputInfo *II = new InputInfo();
+  std::unique_ptr<InputInfo> II(new InputInfo());
 
   C->AddRareFeature(FeatIdx1);
-  C->UpdateFeatureFrequency(II, FeatIdx1);
+  C->UpdateFeatureFrequency(II.get(), FeatIdx1);
   EXPECT_EQ(II->FeatureFreqs.size(), One);
   C->AddRareFeature(FeatIdx2);
-  C->UpdateFeatureFrequency(II, FeatIdx1);
-  C->UpdateFeatureFrequency(II, FeatIdx2);
+  C->UpdateFeatureFrequency(II.get(), FeatIdx1);
+  C->UpdateFeatureFrequency(II.get(), FeatIdx2);
   EXPECT_EQ(II->FeatureFreqs.size(), Two);
   EXPECT_EQ(II->FeatureFreqs[0].second, 2);
   EXPECT_EQ(II->FeatureFreqs[1].second, 1);
 
   C->AddRareFeature(FeatIdx3);
   C->AddRareFeature(FeatIdx4);
-  C->UpdateFeatureFrequency(II, FeatIdx3);
-  C->UpdateFeatureFrequency(II, FeatIdx3);
-  C->UpdateFeatureFrequency(II, FeatIdx3);
-  C->UpdateFeatureFrequency(II, FeatIdx4);
+  C->UpdateFeatureFrequency(II.get(), FeatIdx3);
+  C->UpdateFeatureFrequency(II.get(), FeatIdx3);
+  C->UpdateFeatureFrequency(II.get(), FeatIdx3);
+  C->UpdateFeatureFrequency(II.get(), FeatIdx4);
 
   for (Index = 1; Index < II->FeatureFreqs.size(); Index++)
     EXPECT_LT(II->FeatureFreqs[Index - 1].first, II->FeatureFreqs[Index].first);
@@ -1095,7 +1095,7 @@ TEST(Entropic, ComputeEnergy) {
   const double Precision = 0.01;
   struct EntropicOptions Entropic = {true, 0xFF, 100};
   std::unique_ptr<InputCorpus> C(new InputCorpus("", Entropic));
-  InputInfo *II = new InputInfo();
+  std::unique_ptr<InputInfo> II(new InputInfo());
   Vector<std::pair<uint32_t, uint16_t>> FeatureFreqs = {{1, 3}, {2, 3}, {3, 3}};
   II->FeatureFreqs = FeatureFreqs;
   II->NumExecutedMutations = 0;


        


More information about the llvm-commits mailing list