* strftime.c (STRFTIME): return 0 and ERANGE when precision is too

large. [ruby-dev:43284] fixes #4456
  based on r31011.

* test/test_time.rb (TestTime#test_huge_precision): test for #4456.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yugui 2011-05-28 23:31:44 +00:00
parent aed90c7cae
commit 6b47d60e16
4 changed files with 16 additions and 1 deletions

View file

@ -309,6 +309,7 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str
i = rb_strftime_with_timespec(s, endp - s, fmt, vtm, timev, ts, gmt); \
if (!i) return 0; \
if (precision > i) {\
NEEDS(precision); \
memmove(s + precision - i, s, i);\
memset(s, padding ? padding : ' ', precision - i); \
s += precision; \