From 163a6e81b207525e4f35e21464ee5ab3afbd3cb5 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 23 Dec 2003 10:43:04 +0000 Subject: * io.c (rb_io_ungetc): raise an exception at unread stream to avoid unspecified behavior. [ruby-dev:22330] * test/ruby/test_system.rb (test_syntax): glob relatively from __FILE__. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index 87caa7651f..8ecf0c1426 100644 --- a/io.c +++ b/io.c @@ -1314,8 +1314,9 @@ rb_io_ungetc(io, c) int cc = NUM2INT(c); GetOpenFile(io, fptr); + if (!(fptr->mode & FMODE_RBUF)) + rb_raise(rb_eIOError, "unread stream"); rb_io_check_readable(fptr); - flush_before_seek(fptr); if (ungetc(cc, fptr->f) == EOF && cc != EOF) rb_sys_fail(fptr->path); @@ -3456,7 +3457,7 @@ rb_io_ctl(io, req, arg, io_p) rb_raise(rb_eArgError, "return value overflowed string"); } - if (fptr->f2 && fileno(fptr->f) != fileno(fptr->f2)) { + if (fptr->f2 && fileno(fptr->f) != fileno(fptr->f2)) { /* call on f2 too; ignore result */ io_cntl(fileno(fptr->f2), cmd, narg, io_p); } -- cgit v1.2.3