The vulnerability GHSA-pvgc-g7gj-pv6h ("Out-of-bounds read in case-insensitive backreference matching") is an out-of-bounds read in Ruby's Onigmo regular-expression engine. The fixing commit on the v3_4 branch, b469749b37d57d2cb293918a895c5bec562d7eb2 ("Check the end of the subject in string_cmp_ic"), touches only regexec.c and adds exactly one line to the static helper string_cmp_ic, plus a regression test named test_backref_ignorecase_at_end_of_string.
Root cause: string_cmp_ic is the helper that compares the subject text against the text captured by a backreference when the IGNORECASE option is in effect. It walks the captured text (bounded by end1 = s1 + mblen) and folds the corresponding subject characters with ONIGENC_MBC_CASE_FOLD, which advances the subject pointer s2 by the number of bytes produced by the fold. The loop only checked the captured side (s1 < end1) and never verified that s2 was still inside the subject buffer (text_end). If a captured character and the subject character have case folds of different byte lengths, s2 can advance past text_end and the next ONIGENC_MBC_CASE_FOLD call reads memory beyond the end of the subject string — an out-of-bounds read that can leak memory or crash the process. The patch adds if (s2 >= text_end) return 0; before folding, which is the missing bounds check. Because a backreference is reached from the interpreter via match_at -> backref_match / backref_match_at_nested_level (handling OP_BACKREFN_IC / OP_BACKREF_MULTI_IC / OP_BACKREF_WITH_LEVEL), those callers are part of the exploit call path, but the function that actually contains the defect and the missing check is string_cmp_ic.
Note: The sibling advisories in the same Ruby release are distinct — GHSA-wpqw-5qxg-m68r (case-insensitive match) is fixed in str_lower_case_match, and the case-insensitive exact-match OOB is fixed in match_at (OP_EXACT1_IC / OP_EXACTN_IC). The one that specifically concerns backreference matching (matching the advisory text and the test_backref_ignorecase_at_end_of_string test) is the string_cmp_ic fix analyzed here.