The vulnerability (GHSA-7x2q-68qv-6p8x, CWE-415 Double Free) is in Ruby's regular-expression compiler (the Onigmo engine, regparse.c). The GitHub security advisory and the Ruby-lang news page state that when parsing a character-class intersection (&&) Ruby could free the same buffer twice. The authoritative fix commit is 0b276cd405cde1732154bdfff4627096143622f5 ("Fix a double free in the && handler of parse_char_class", Reported-by: Stephan Lipp Stephan@Adalogics.com), which matches the advisory credits (Stephan Lipp / Ada Logics).
The patch adds a single line in parse_char_class, inside the && (CCLASS_SET_OP intersection) handler: after bbuf_free(cc->mbuf); it now executes cc->mbuf = NULL;. In the vulnerable code, the buffer pointer was left dangling in cc; the immediately following and_cclass(asc_prev_cc, asc_cc, env) call (for the ASCII-only intersection class) can fail, jumping to the err: cleanup label, which calls bbuf_free(cc->mbuf) again on the already-freed buffer. That is the double free. Because cc->mbuf was never cleared, the free is performed twice on the same heap address, giving an attacker-controlled heap corruption primitive.
The trigger is reachable from Ruby-level code via Regexp.new / Regexp#initialize → rb_reg_initialize → rb_reg_compile → onig_new → onig_parse_make_tree → parse_subexp → parse_branch → parse_exp → parse_char_class. The function that actually contains the missing cc->mbuf = NULL reset (the root cause and the location where the malicious pattern is processed) is parse_char_class in regparse.c. This is a native C function of the regexp engine; it appears in a native/stack profile as parse_char_class (no namespace, since it is a static C function).
Recommended remediation: upgrade to Ruby 3.3.14 / 3.4.13 / 4.0.10, which include the parse_char_class fix.