* string.c: add internal API rb_str_locktmp_ensure().

* io.c (io_fread): use rb_str_locktmp_ensure().
  [ruby-core:56121] [Bug #8669]

* test/ruby/test_io.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e