summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-07 14:40:07 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-07 14:40:07 +0000
commit4a5a6f4a2c6a20fb61ab834655fdae8ba4879196 (patch)
treee18fe99e6a2e828026bc38d6e952605509ffebcf /time.c
parent86411a0a761976b6d4ec9d0d841e727f17495c78 (diff)
merge revision(s) 32885:
* 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/branches/ruby_1_9_3@32886 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 b2e3448610..5122466675 100644
--- a/time.c
+++ b/time.c
@@ -4326,8 +4326,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;
}