[llvm] [FIX] Fix undefined-behaviour in regex engine. (PR #73071)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 29 00:41:48 PST 2023


================
@@ -82,8 +82,8 @@ unsigned Regex::getNumMatches() const {
 
 bool Regex::match(StringRef String, SmallVectorImpl<StringRef> *Matches,
                   std::string *Error) const {
-  // Exit without match if string is empty
-  if (String.empty())
+  // No match for null string data
+  if (String.data() == nullptr)
----------------
nikic wrote:

Now can we have a non-empty string with nullptr data?

https://github.com/llvm/llvm-project/pull/73071


More information about the llvm-commits mailing list