[PATCH] D39212: Check special-case-list regex before insertion.

Mitch Phillips via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 16:37:53 PDT 2017


hctim updated this revision to Diff 120147.
hctim added a comment.

- Added unit test to catch fuzz failure.


https://reviews.llvm.org/D39212

Files:
  lib/Support/SpecialCaseList.cpp
  unittests/Support/SpecialCaseListTest.cpp


Index: unittests/Support/SpecialCaseListTest.cpp
===================================================================
--- unittests/Support/SpecialCaseListTest.cpp
+++ unittests/Support/SpecialCaseListTest.cpp
@@ -67,6 +67,9 @@
 
   EXPECT_EQ(makeSpecialCaseList("[[]", Error), nullptr);
   EXPECT_TRUE(((StringRef)Error).startswith("malformed regex for section [: "));
+
+  EXPECT_EQ(makeSpecialCaseList("src:=", Error), nullptr);
+  EXPECT_TRUE(((StringRef)Error).endswith("Supplied regexp was blank"));
 }
 
 TEST_F(SpecialCaseListTest, Section) {
Index: lib/Support/SpecialCaseList.cpp
===================================================================
--- lib/Support/SpecialCaseList.cpp
+++ lib/Support/SpecialCaseList.cpp
@@ -28,6 +28,11 @@
 
 bool SpecialCaseList::Matcher::insert(std::string Regexp,
                                       std::string &REError) {
+  if (Regexp.empty()) {
+    REError = "Supplied regexp was blank";
+    return false;
+  }
+
   if (Regex::isLiteralERE(Regexp)) {
     Strings.insert(Regexp);
     return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39212.120147.patch
Type: text/x-patch
Size: 1052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171024/bf8afbc2/attachment.bin>


More information about the llvm-commits mailing list