Fix segfault on remove_method with invalid argument

Reported by https://hackerone.com/jpenalbae
This commit is contained in:
Bouke van der Bijl
2016-11-14 17:57:43 -05:00
parent a630c4f413
commit 22f5504054
2 changed files with 10 additions and 1 deletions
+9
View File
@@ -401,3 +401,12 @@ assert('class with non-class/module outer raises TypeError') do
assert_raise(TypeError) { class 0::C1; end }
assert_raise(TypeError) { class []::C2; end }
end
assert("remove_method doesn't segfault if the passed in argument isn't a symbol") do
klass = Class.new
assert_raise(TypeError) { klass.remove_method nil }
assert_raise(TypeError) { klass.remove_method 123 }
assert_raise(TypeError) { klass.remove_method 1.23 }
assert_raise(NameError) { klass.remove_method "hello" }
assert_raise(TypeError) { klass.remove_method Class.new }
end