summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--array.c1
2 files changed, 7 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 2487728834..153543cd3f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Dec 10 21:00:30 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_slice_bang): should return nil if position out
+ of range. a patch from Akinori MUSHA <knu AT iDaemons.org>.
+ [ruby-dev:32518]
+
Mon Dec 10 19:02:52 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* re.c (rb_reg_match): should calculate offset by converted
diff --git a/array.c b/array.c
index 4eaf0c7ddc..30caf7b5da 100644
--- a/array.c
+++ b/array.c
@@ -1888,6 +1888,7 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary)
delete_pos_len:
if (pos < 0) {
pos = RARRAY_LEN(ary) + pos;
+ if (pos < 0) return Qnil;
}
arg2 = rb_ary_subseq(ary, pos, len);
rb_ary_splice(ary, pos, len, Qundef); /* Qnil/rb_ary_new2(0) */