From: Nobuyoshi Nakada Date: 2011-07-22T00:57:17+09:00 Subject: [ruby-dev:44182] Re: [Ruby 1.9 - Bug #4457] Time#strftime で %z 指定子などに大きな幅を指定した際の不具合 なかだです。 At Thu, 21 Jul 2011 13:57:30 +0900, Motohiro KOSAKI wrote in [ruby-dev:44176]: > こちら、状況いかがでしょうか? できなければ例外、ですかねぇ。 diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 38e567a..1f07a82 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -650,6 +650,9 @@ class TestTime < Test::Unit::TestCase # [ruby-core:33985] assert_equal("3000000000", Time.at(3000000000).strftime('%s')) + + bug4457 = '[ruby-dev:43285]' + assert_raise(Errno::ERANGE, bug4457) {Time.now.strftime('%8192z')} end def test_delegate Modified time.c diff --git a/time.c b/time.c index dd846a6..6817c75 100644 --- a/time.c +++ b/time.c @@ -4325,8 +4325,12 @@ rb_strftime_alloc(char **buf, const char *format, * if the buffer is 1024 times bigger than the length of the * format string, it's not failing for lack of room. */ - if (len > 0 || size >= 1024 * flen) break; + if (len > 0) break; xfree(*buf); + if (size >= 1024 * flen) { + rb_sys_fail(format); + break; + } } return len; } -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦