aboutsummaryrefslogtreecommitdiffstats
path: root/time.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-07 14:38:17 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-07 14:38:17 +0000
commitf2f14f572d6fb92394955953352e6edb688cc986 (patch)
tree5c9ba4dad1d98cb1b01ce1b84c94d1c1b677fc63 /time.c
parent9c760d0aad3fac021dcfa7d7c80609cd4178d9c9 (diff)
downloadruby-f2f14f572d6fb92394955953352e6edb688cc986.tar.gz
* time.c (rb_strftime_alloc): raise ERANGE if width is too large.
Patch by Nobuyoshi Nakada. [Bug #4457] [ruby-dev:43285] * test/ruby/test_time.rb (class TestTime): add a test for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/time.c b/time.c
index dd846a630c..6817c75e1e 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;
}