ruby/ruby — pull request #192 by alexdowad (2012-10-11 19:40:58+00:00)
Title: Use RB_GC_GUARD to prevent GC from freeing String copies used by iterators (reloaded)

This fixes the following bug: http://bugs.ruby-lang.org/issues/7135

Although the problem I encountered was from String#codepoints, String#chars and String#lines are implemented in a similar way, and it looks like the same problem could potentially affect them too. So this patch includes "preemptive" fixes for those 2 as well.

The bug affects Ruby 1.9.2, 1.9.3, and 2.0. I've checked that the patch applies cleanly to both v1_9_2_381 and v1_9_3_195. I recommend you cherry-pick it onto both the 1.9.2 and 1.9.3 maintenance branches.