diff --git a/src/parser/AsciiComponentClass.cpp b/src/parser/AsciiComponentClass.cpp index de7a40d4..44ecb5bb 100644 --- a/src/parser/AsciiComponentClass.cpp +++ b/src/parser/AsciiComponentClass.cpp @@ -52,7 +52,8 @@ AsciiComponentClass *AsciiComponentClass::clone() const { } bool AsciiComponentClass::class_empty(void) const { - return cr.none() && cr_ucp.none(); + assert(finalized); + return cr.none(); } void AsciiComponentClass::createRange(unichar to) { diff --git a/src/parser/ComponentClass.cpp b/src/parser/ComponentClass.cpp index 4570734d..43c05898 100644 --- a/src/parser/ComponentClass.cpp +++ b/src/parser/ComponentClass.cpp @@ -441,7 +441,6 @@ void ComponentClass::addDash(void) { } void ComponentClass::negate() { - assert(class_empty()); m_negate = true; } diff --git a/src/parser/ComponentClass.h b/src/parser/ComponentClass.h index ce3b49f3..1cb1a7d0 100644 --- a/src/parser/ComponentClass.h +++ b/src/parser/ComponentClass.h @@ -232,8 +232,12 @@ public: Component *accept(ComponentVisitor &v) override = 0; void accept(ConstComponentVisitor &v) const override = 0; - /** True iff we have already started adding members to the class. This is - * a different concept to Component::empty */ + /** \brief True if the class contains no members (i.e. it will not match + * against anything). This function can only be called on a finalized + * class. + * + * Note: This is a different concept to Component::empty. + */ virtual bool class_empty(void) const = 0; virtual void add(PredefinedClass c, bool negated) = 0; diff --git a/src/parser/Utf8ComponentClass.cpp b/src/parser/Utf8ComponentClass.cpp index 72fc2146..3a6a85a4 100644 --- a/src/parser/Utf8ComponentClass.cpp +++ b/src/parser/Utf8ComponentClass.cpp @@ -484,7 +484,8 @@ UTF8ComponentClass *UTF8ComponentClass::clone() const { } bool UTF8ComponentClass::class_empty(void) const { - return cps.none() && cps_ucp.none(); + assert(finalized); + return cps.none(); } void UTF8ComponentClass::createRange(unichar to) { diff --git a/unit/hyperscan/bad_patterns.txt b/unit/hyperscan/bad_patterns.txt index 837ba871..3b13e064 100644 --- a/unit/hyperscan/bad_patterns.txt +++ b/unit/hyperscan/bad_patterns.txt @@ -132,3 +132,4 @@ 132:/[a[==]]/ #Unsupported POSIX collating element at index 2. 133:/[a[.\].]]/ #Unsupported POSIX collating element at index 2. 134:/[a[=\]=]]/ #Unsupported POSIX collating element at index 2. +135:/[^\D\d]/8W #Pattern can never match.