[ruby/stringio] Fix SEGV at unget to a null device StringIO
https://github.com/ruby/stringio/commit/eb4ee49218
This commit is contained in:
parent
fa6b9f75ef
commit
7ef9110b1e
@ -180,7 +180,9 @@ check_modifiable(struct StringIO *ptr)
|
||||
else if (OBJ_FROZEN_RAW(ptr->string)) {
|
||||
rb_raise(rb_eIOError, "not modifiable string");
|
||||
}
|
||||
rb_str_modify(ptr->string);
|
||||
else {
|
||||
rb_str_modify(ptr->string);
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -64,6 +64,10 @@ class TestStringIO < Test::Unit::TestCase
|
||||
assert_nil io.gets
|
||||
io.puts "abc"
|
||||
assert_nil io.string
|
||||
|
||||
# Null device StringIO just drop ungot string
|
||||
io.ungetc '#'
|
||||
assert_nil io.getc
|
||||
end
|
||||
|
||||
def test_truncate
|
||||
|
Loading…
x
Reference in New Issue
Block a user