Copilot commented on code in PR #13671:
URL: https://github.com/apache/trafficserver/pull/13671#discussion_r3997452248
##########
src/tsutil/Regex.cc:
##########
@@ -330,6 +390,14 @@ Regex::Regex(Regex const &other)
if (other_code != nullptr) {
// Use PCRE2's built-in function to deep copy the compiled pattern
auto *copied_code = pcre2_code_copy(other_code);
+
+ // pcre2_code_copy() does not carry the machine code the JIT produced,
because that
+ // code is position dependent. Without this the copy would match on the
interpreter:
+ // same answers, much slower, and a different set of resource limits, so a
pattern
+ // that reports a JIT stack limit through the original would quietly match
through
+ // the copy. Compile it again, exactly as Regex::compile() does for a new
pattern.
+ pcre2_jit_compile(copied_code, PCRE2_JIT_COMPLETE);
+
_Code::set(_code, copied_code);
Review Comment:
`pcre2_code_copy()` can return `nullptr` on allocation failure. This
unconditional call passes that null pointer to `pcre2_jit_compile`, turning a
recoverable copy failure into a crash; guard the JIT step and only publish the
copied code when the copy succeeded.
--
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]