ezelkow1 commented on code in PR #13441:
URL: https://github.com/apache/trafficserver/pull/13441#discussion_r3731916735


##########
src/tsutil/Regex.cc:
##########
@@ -205,6 +205,13 @@ RegexMatches::operator[](size_t index) const
   }
 
   PCRE2_SIZE *ovector = 
pcre2_get_ovector_pointer(_MatchData::get(_match_data));
+
+  // A group that did not participate in the match has an unset offset. This 
happens for an optional
+  // group that precedes a participating one, so a valid index is not enough 
to guarantee an offset.
+  if (PCRE2_UNSET == ovector[2 * index]) {
+    return std::string_view();
+  }
+
   return std::string_view(_subject.data() + ovector[2 * index], ovector[2 * 
index + 1] - ovector[2 * index]);

Review Comment:
   Approving as long as you are ok with this



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to