diff options
-rw-r--r-- | ext/pty/pty.c | 14 | ||||
-rw-r--r-- | lib/English.rb | 1 | ||||
-rw-r--r-- | lib/cgi/session.rb | 4 | ||||
-rw-r--r-- | lib/delegate.rb | 38 | ||||
-rw-r--r-- | sample/test.rb | 7 |
5 files changed, 41 insertions, 23 deletions
diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 3bf100ef20..748869865e 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -361,8 +361,8 @@ freeDevice() /* ruby function: getpty */ static VALUE -pty_getpty(self, shell) - VALUE self, shell; +pty_getpty(self, command) + VALUE self, command; { VALUE res, th; struct pty_info info; @@ -373,15 +373,19 @@ pty_getpty(self, shell) MakeOpenFile(rport, rfptr); MakeOpenFile(wport, wfptr); - establishShell(RSTRING(shell)->ptr,&info); + if (TYPE(command) == T_ARRAY) + command = rb_ary_join(command,rb_str_new2(" ")); + Check_SafeStr(command); + + establishShell(RSTRING(command)->ptr,&info); rfptr->mode = rb_io_mode_flags("r"); rfptr->f = fdopen(info.fd, "r"); - rfptr->path = strdup(RSTRING(shell)->ptr); + rfptr->path = strdup(RSTRING(command)->ptr); wfptr->mode = rb_io_mode_flags("w"); wfptr->f = fdopen(dup(info.fd), "w"); - wfptr->path = strdup(RSTRING(shell)->ptr); + wfptr->path = strdup(RSTRING(command)->ptr); res = rb_ary_new2(3); rb_ary_store(res,0,(VALUE)rport); diff --git a/lib/English.rb b/lib/English.rb index c7e13bebe6..9682722027 100644 --- a/lib/English.rb +++ b/lib/English.rb @@ -1,4 +1,3 @@ - alias $ERROR_INFO $! alias $ERROR_POSITION $@ alias $LOADED_FEATURES $" diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb index 23c9bdc2a4..bd087bb5ea 100644 --- a/lib/cgi/session.rb +++ b/lib/cgi/session.rb @@ -81,7 +81,7 @@ class CGI unless @data @data = @dbman.restore end - @data[key] = String(val) + @data[key] = val end def update @@ -139,7 +139,7 @@ class CGI def update @f.rewind for k,v in @hash - @f.printf "%s=%s\n", CGI::escape(k), CGI::escape(v) + @f.printf "%s=%s\n", CGI::escape(k), CGI::escape(String(v)) end @f.truncate @f.tell end diff --git a/lib/delegate.rb b/lib/delegate.rb index a72ea943ba..ecc23d52ea 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -29,17 +29,21 @@ class Delegator end for method in obj.methods next if preserved.include? method - eval <<-EOS - def self.#{method}(*args, &block) - begin - __getobj__.__send__(:#{method}, *args, &block) - rescue Exception - $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #` - $@.delete_if{|s| /^\\(eval\\):/ =~ s} - raise + begin + eval <<-EOS + def self.#{method}(*args, &block) + begin + __getobj__.__send__(:#{method}, *args, &block) + rescue Exception + $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #` + $@.delete_if{|s| /^\\(eval\\):/ =~ s} + raise + end end - end - EOS + EOS + rescue SyntaxError + raise NameError, "invalid identifier %s" % method, caller(4) + end end end @@ -81,8 +85,9 @@ def DelegateClass(superclass) end EOS for method in methods - klass.module_eval <<-EOS - def #{method}(*args, &block) + begin + klass.module_eval <<-EOS + def #{method}(*args, &block) begin @obj.__send__(:#{method}, *args, &block) rescue @@ -90,10 +95,13 @@ def DelegateClass(superclass) raise end end - EOS - end - return klass; + EOS + rescue SyntaxError + raise NameError, "invalid identifier %s" % method, caller(3) + end end + return klass; +end if __FILE__ == $0 class ExtArray<DelegateClass(Array) diff --git a/sample/test.rb b/sample/test.rb index 4ee6ddcec8..b342fb8541 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -1338,6 +1338,13 @@ l=nil 100000.times { l = S.new(l) } +GC.start +test_ok true # reach here or dumps core +l = [] +100000.times { + l.push([l]) +} +GC.start test_ok true # reach here or dumps core if $failed > 0 |