stringio.c: check range
* ext/stringio/stringio.c (strio_ungetc): raise RangeError instead of TypeError at too big value, as well as IO#ungetc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
853ab8662f
commit
c8d66b5d82
@ -766,8 +766,8 @@ strio_ungetc(VALUE self, VALUE c)
|
|||||||
|
|
||||||
check_modifiable(ptr);
|
check_modifiable(ptr);
|
||||||
if (NIL_P(c)) return Qnil;
|
if (NIL_P(c)) return Qnil;
|
||||||
if (FIXNUM_P(c)) {
|
if (RB_INTEGER_TYPE_P(c)) {
|
||||||
int len, cc = FIX2INT(c);
|
int len, cc = NUM2INT(c);
|
||||||
char buf[16];
|
char buf[16];
|
||||||
|
|
||||||
enc = rb_enc_get(ptr->string);
|
enc = rb_enc_get(ptr->string);
|
||||||
|
@ -455,6 +455,7 @@ class TestStringIO < Test::Unit::TestCase
|
|||||||
assert_equal("2", f.getc)
|
assert_equal("2", f.getc)
|
||||||
|
|
||||||
assert_raise(RangeError) {f.ungetc(0x1ffffff)}
|
assert_raise(RangeError) {f.ungetc(0x1ffffff)}
|
||||||
|
assert_raise(RangeError) {f.ungetc(0xffffffffffffff)}
|
||||||
ensure
|
ensure
|
||||||
f.close unless f.closed?
|
f.close unless f.closed?
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user