diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-07-24 16:55:12 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-07-24 16:55:12 -0700 |
| commit | ec309c6fd7a8e177be4d1c5cd3cebfcf2088a52d (patch) | |
| tree | d855fd0600b0ce01abcecf0be639013f0518a256 /src | |
| parent | 08213e32e817f83313b1586d76c0e8735ba210e7 (diff) | |
| parent | f114e3e25236cd43d2f71419e4929caaa755020e (diff) | |
| download | mruby-ec309c6fd7a8e177be4d1c5cd3cebfcf2088a52d.tar.gz mruby-ec309c6fd7a8e177be4d1c5cd3cebfcf2088a52d.zip | |
Merge pull request #393 from akuroda/array_last_fix
fix segmentation fault in Array#last
Diffstat (limited to 'src')
| -rw-r--r-- | src/array.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/array.c b/src/array.c index ed1c3f475..0f52c38ef 100644 --- a/src/array.c +++ b/src/array.c @@ -789,6 +789,9 @@ mrb_ary_last(mrb_state *mrb, mrb_value self) /* len == 1 */ size = mrb_fixnum(*vals); + if (size < 0) { + mrb_raise(mrb, E_ARGUMENT_ERROR, "negative array size"); + } if (size > a->len) size = a->len; if ((a->flags & MRB_ARY_SHARED) || size > ARY_DEFAULT_LEN) { return ary_subseq(mrb, a, a->len - size, size); |
