The bug here is in the C code for Ruby. Python is also written in C and just as likely to have memory bugs.
CPython.