summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-14 08:08:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-14 08:08:15 +0000
commit8d6add973ebcb3b4c1efbfaf07786550a3e219af (patch)
tree56acd1cb74d4903170ca45655843138ce53a1937 /hash.c
parente81c1d53feb6c65b354c9a63b9da799ce4d82026 (diff)
hash.c: raise on invalid input
* hash.c (rb_hash_s_create): raise an exception, when input elements are not one or two elements arrays. [ruby-core:39945] [Bug #5406] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index 22aa86da87..06d0ce9e68 100644
--- a/hash.c
+++ b/hash.c
@@ -393,8 +393,13 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
VALUE v = rb_check_array_type(RARRAY_PTR(tmp)[i]);
VALUE key, val = Qnil;
- if (NIL_P(v)) continue;
+ if (NIL_P(v)) {
+ rb_raise(rb_eArgError, "wrong element type (expected array)");
+ }
switch (RARRAY_LEN(v)) {
+ default:
+ rb_raise(rb_eArgError, "invalid number of elements (%ld for 1..2)",
+ RARRAY_LEN(v));
case 2:
val = RARRAY_PTR(v)[1];
case 1: