From: Minero Aoki Date: 2002-09-06T02:14:45+09:00 Subject: [ruby-dev:18194] [PATCH] "puts str.rstrip.gsub" causes SEGV あおきです。 以下のプログラムでSEGVします。 puts " ".dup.rstrip.gsub(/a/, '') とりあえず添付のパッチで治りました。 そもそも ptr[len-1] がまずそうなので len を見てチェックして みたんですが、StringValuePtr() を使うほうがいいんでしょうか。 ------------------------------------------------------------------- 青木峰郎 Index: io.c =================================================================== RCS file: /home/aamine/cvs/ruby/ruby/io.c,v retrieving revision 1.155 diff -u -p -r1.155 io.c --- io.c 3 Sep 2002 05:20:06 -0000 1.155 +++ io.c 5 Sep 2002 17:03:28 -0000 @@ -2451,7 +2451,8 @@ rb_io_puts(argc, argv, out) line = rb_obj_as_string(argv[i]); } rb_io_write(out, line); - if (RSTRING(line)->ptr[RSTRING(line)->len-1] != '\n') { + if (RSTRING(line)->len == 0 || + RSTRING(line)->ptr[RSTRING(line)->len-1] != '\n') { rb_io_write(out, rb_default_rs); } }