Skip to content

Commit

Permalink
encoding.c: check external encoding
Browse files Browse the repository at this point in the history
* encoding.c (rb_enc_get_index): external encoding may not be Data
  object.  [ruby-core:89016] [Bug #15122]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Sep 15, 2018
1 parent 97f8d0f commit e040465
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ rb_enc_get_index(VALUE obj)
if (NIL_P(tmp)) {
tmp = rb_funcallv(obj, rb_intern("external_encoding"), 0, 0);
}
if (is_data_encoding(tmp)) {
if (is_obj_encoding(tmp)) {
i = enc_check_encoding(tmp);
}
break;
Expand Down
7 changes: 7 additions & 0 deletions test/ruby/test_io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3855,4 +3855,11 @@ def test_select_leak
th.join
end;
end

def test_external_encoding_index
IO.pipe {|r, w|
assert_raise(TypeError) {Marshal.dump(r)}
assert_raise(TypeError) {Marshal.dump(w)}
}
end
end

0 comments on commit e040465

Please sign in to comment.