[llvm] [FIX] Fix undefined-behaviour in regex engine. (PR #73071)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 29 00:53:46 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)
----------------
tanmaysachan wrote:
I believe the empty() checks were failing because a size 0 string and null string both were returning true for it. And an empty regex can match with an empty string?
https://github.com/llvm/llvm-project/pull/73071
More information about the llvm-commits
mailing list