The vulnerability lies in an integer truncation issue within the rdiscount Ruby gem, leading to an out-of-bounds read and a denial-of-service. The core of the problem is in the C-extension code. The Ruby methods RDiscount.to_html and RDiscount.toc_content, implemented by the C functions rb_rdiscount_to_html and rb_rdiscount_toc_content respectively, would take a user-supplied string. The length of this string, represented as a long integer, was passed to the internal mkd_string function. However, mkd_string accepts the length as a standard int. When an input string with a length greater than INT_MAX (2,147,483,647 bytes) was processed, the long value was truncated to a negative int. This negative value was then used in the parsing logic, specifically in __mkd_io_strget, causing it to read memory far beyond the intended buffer, which reliably crashed the process. The patch addresses this by adding a validation function, rb_rdiscount__text_len, which checks if the input length exceeds INT_MAX and raises an exception if it does, preventing the unsafe call to mkd_string.