[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:43:16 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:
Pretty sure this indicates a bug in some caller. Possibly the StringRef Data + Length constructor should be asserting that if Length != 0 then also Data != nullptr.
https://github.com/llvm/llvm-project/pull/73071
More information about the llvm-commits
mailing list