From bf22dff8ea5f3ac94ab1a354abea48fd7c3f272c Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 3 Sep 2004 17:41:27 +0000 Subject: [PATCH] * eval.c (cvar_cbase): class variables cause SEGV in instance_eval() for fixnums and symbols. [ruby-dev:24213] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ eval.c | 3 +++ math.c | 23 ----------------------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index e14357c40f..ae9bbb9bc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Sep 4 01:14:57 2004 Yukihiro Matsumoto + + * eval.c (cvar_cbase): class variables cause SEGV in + instance_eval() for fixnums and symbols. [ruby-dev:24213] + Fri Sep 3 17:47:58 2004 Yukihiro Matsumoto * struct.c (make_struct): remove redefining constant when diff --git a/eval.c b/eval.c index 46c687dc4e..ac3ff420b5 100644 --- a/eval.c +++ b/eval.c @@ -1779,6 +1779,9 @@ cvar_cbase() rb_warn("class variable access from toplevel singleton method"); } } + if (NIL_P(cref->nd_clss)) { + rb_raise(rb_eTypeError, "no class variables available"); + } return cref->nd_clss; } diff --git a/math.c b/math.c index cea7bb801d..5b9294e781 100644 --- a/math.c +++ b/math.c @@ -331,28 +331,6 @@ math_log(obj, x) return rb_float_new(d); } -/* - * call-seq: - * Math.log2(numeric) => float - * - * Returns the base 2 logarithm of numeric. - */ - -static VALUE -math_log2(obj, x) - VALUE obj, x; -{ - double d; - - Need_Float(x); - errno = 0; - d = log2(RFLOAT(x)->value); - if (errno) { - rb_sys_fail("log2"); - } - return rb_float_new(d); -} - /* * call-seq: * Math.log10(numeric) => float @@ -533,7 +511,6 @@ Init_Math() rb_define_module_function(rb_mMath, "exp", math_exp, 1); rb_define_module_function(rb_mMath, "log", math_log, 1); - rb_define_module_function(rb_mMath, "log2", math_log, 1); rb_define_module_function(rb_mMath, "log10", math_log10, 1); rb_define_module_function(rb_mMath, "sqrt", math_sqrt, 1);