summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-14 15:45:42 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-14 15:45:42 +0000
commit108d1632e1ae83790692293047c3333220c1c9fd (patch)
treef18c7f46dd5d4f92a696cb1bb0b6724213e37df6 /time.c
parent844f78f5564aeadb846cd7c8eec8e1dd507f7f60 (diff)
merge revision(s) 39967: [Backport #8193]
* 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/branches/ruby_2_0_0@40298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/time.c b/time.c
index 7a877186e2..2173fcda8e 100644
--- a/time.c
+++ b/time.c
@@ -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;
}