diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-27 11:37:59 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-27 11:37:59 +0000 |
commit | c64f26a28171e3e9400f027e63d02dc5af5f8ca5 (patch) | |
tree | 8152ceb167dc4162839874aab7446eb40d251574 /time.c | |
parent | 2f1e7f6a71a1eaaa753c3ed2e897fd4d4771f2ea (diff) |
* time.c (num_exact): use to_r method only if to_int method is
available.
[ruby-core:53764] [Bug #8173] reported by Hiro Asari.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -683,7 +683,9 @@ num_exact(VALUE v) default: if ((tmp = rb_check_funcall(v, rb_intern("to_r"), 0, NULL)) != Qundef) { - if (rb_respond_to(v, rb_intern("to_str"))) goto typeerror; + /* test to_int method availability to reject non-Numeric + * objects such as String, Time, etc which have to_r method. */ + if (!rb_respond_to(v, rb_intern("to_int"))) goto typeerror; v = tmp; break; } |