Skip to content

Commit d396f66

Browse files
committed
merge revision(s) r47715: [Backport ruby#10282]
* object.c (rb_class_real): do not dereference 0 VALUE * test/ruby/test_module.rb (test_inspect_segfault): Test case and bug report by Thomas Stratmann. [ruby-core:65214] [Bug ruby#10282] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 982aab0 commit d396f66

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Thu Oct 16 00:20:12 2014 Eric Wong <[email protected]>
2+
3+
* object.c (rb_class_real): do not dereference 0 VALUE
4+
5+
* test/ruby/test_module.rb (test_inspect_segfault):
6+
Test case and bug report by Thomas Stratmann.
7+
[ruby-core:65214] [Bug #10282]
8+
19
Thu Oct 16 00:10:45 2014 Nobuyoshi Nakada <[email protected]>
210

311
* signal.c (rb_f_kill): get rid of deadlock as unhandled and

object.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,8 @@ rb_obj_not_equal(VALUE obj1, VALUE obj2)
203203
VALUE
204204
rb_class_real(VALUE cl)
205205
{
206-
if (cl == 0)
207-
return 0;
208-
while ((RBASIC(cl)->flags & FL_SINGLETON) || BUILTIN_TYPE(cl) == T_ICLASS) {
206+
while (cl &&
207+
((RBASIC(cl)->flags & FL_SINGLETON) || BUILTIN_TYPE(cl) == T_ICLASS)) {
209208
cl = RCLASS_SUPER(cl);
210209
}
211210
return cl;

test/ruby/test_module.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,30 @@ def foo; end
19571957
}
19581958
end
19591959

1960+
def test_inspect_segfault
1961+
bug_10282 = '[ruby-core:65214] [Bug #10282]'
1962+
assert_separately [], <<-RUBY
1963+
module ShallowInspect
1964+
def shallow_inspect
1965+
"foo"
1966+
end
1967+
end
1968+
1969+
module InspectIsShallow
1970+
include ShallowInspect
1971+
alias_method :inspect, :shallow_inspect
1972+
end
1973+
1974+
class A
1975+
end
1976+
1977+
A.prepend InspectIsShallow
1978+
1979+
expect = "#<Method: A(Object)#inspect(shallow_inspect)>"
1980+
assert_equal expect, A.new.method(:inspect).inspect, "#{bug_10282}"
1981+
RUBY
1982+
end
1983+
19601984
private
19611985

19621986
def assert_top_method_is_private(method)

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.4"
22
#define RUBY_RELEASE_DATE "2014-10-16"
3-
#define RUBY_PATCHLEVEL 255
3+
#define RUBY_PATCHLEVEL 256
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 10

0 commit comments

Comments
 (0)