Project

General

Profile

Actions

Bug #4131

closed

can't set length of shared string error in IO#read

Added by tarui (Masaya Tarui) over 13 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-12-07 trunk 30119) [i386-mswin32_90]
Backport:
[ruby-dev:42719]

Description

=begin
IO#readにおいて、
lengthがnilでbufferにsharedなStringを指定したときに以下のようにエラーになります。

ruby -ve "a='abcdefghijkl';b=a[1,3];STDIN.read(nil,a)"
ruby 1.9.3dev (2010-12-07 trunk 30119) [i386-mswin32_90]
-e:1:in read': can't set length of shared string (RuntimeError) from -e:1:in '

patchを貼り付けますが、この後、他のbugfixのためにリファクタリング予定です。
Index: io.c

--- io.c (リビジョン 30119)
+++ io.c (作業コピー)
@@ -2212,7 +2212,10 @@
rb_scan_args(argc, argv, "02", &length, &str);

  if (NIL_P(length)) {
  •   if (!NIL_P(str)) StringValue(str);
    
  •   if (!NIL_P(str)){
    
  •       StringValue(str);
    
  •       rb_str_modify(str);
    
  •   }
      GetOpenFile(io, fptr);
      rb_io_check_char_readable(fptr);
      return read_all(fptr, remain_size(fptr), str);
    

=end

Actions #1

Updated by tarui (Masaya Tarui) over 13 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r30122.
Masaya, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0