[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,8 +180,10 @@ check_modifiable(struct StringIO *ptr)
|
|||||||
else if (OBJ_FROZEN_RAW(ptr->string)) {
|
else if (OBJ_FROZEN_RAW(ptr->string)) {
|
||||||
rb_raise(rb_eIOError, "not modifiable string");
|
rb_raise(rb_eIOError, "not modifiable string");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
rb_str_modify(ptr->string);
|
rb_str_modify(ptr->string);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
strio_s_allocate(VALUE klass)
|
strio_s_allocate(VALUE klass)
|
||||||
|
@ -64,6 +64,10 @@ class TestStringIO < Test::Unit::TestCase
|
|||||||
assert_nil io.gets
|
assert_nil io.gets
|
||||||
io.puts "abc"
|
io.puts "abc"
|
||||||
assert_nil io.string
|
assert_nil io.string
|
||||||
|
|
||||||
|
# Null device StringIO just drop ungot string
|
||||||
|
io.ungetc '#'
|
||||||
|
assert_nil io.getc
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_truncate
|
def test_truncate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user