diff options
| author | yui-knk <[email protected]> | 2014-05-08 00:17:17 +0900 |
|---|---|---|
| committer | yui-knk <[email protected]> | 2014-05-08 00:17:17 +0900 |
| commit | eafc4dd0afe0db26be0f5abce425af717552fa48 (patch) | |
| tree | 8e5c69016cdb5ab6f8f138fb11af51a8c34dda0e /src/array.c | |
| parent | 09b9c7762df3f75384f8390b9f6b51e2e18f4c5d (diff) | |
| download | mruby-eafc4dd0afe0db26be0f5abce425af717552fa48.tar.gz mruby-eafc4dd0afe0db26be0f5abce425af717552fa48.zip | |
Make Array#[]= raise IndexError.
If second param is negative, Array#[] raise IndexError.
Diffstat (limited to 'src/array.c')
| -rw-r--r-- | src/array.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/array.c b/src/array.c index febc3a7a8..7e9c0139d 100644 --- a/src/array.c +++ b/src/array.c @@ -561,6 +561,10 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val mrb_int i, argc; ary_modify(mrb, a); + + /* len check */ + if (len < 0) mrb_raisef(mrb, E_INDEX_ERROR, "negative length (%S)", mrb_fixnum_value(len)); + /* range check */ if (head < 0) { head += a->len; |
